Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't handle android.intent.package_ADDED and REMOVED error while retrieving location using Fused Location API

I am creating MainActivity class implementing LocationListener, GooglePlayServicesClient to get current location using FusedLocationApi. Its showing me some weird errors but that don't crash my app but functionality don't work. I am putting Log.i() to check whether control enters the overridden methods but it seems control dont enter in those methods. Below is the code and output. Please help

public class MainActivity extends FragmentActivity implements
    GooglePlayServicesClient.ConnectionCallbacks,
    GooglePlayServicesClient.OnConnectionFailedListener, com.google.android.gms.location.LocationListener,android.view.View.OnClickListener   
  {
 private LocationClient mGetLocationLocationClient;
 private LocationRequest mGetLocationLocationRequest;
 private Location mGetLocationcurrentLocation;

 startBtn.setOnClickListener(this);

@Override
protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    Log.i("in onStart", "yes..");
    mGetLocationLocationClient.connect();
}

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    Log.i("in onLocationChanged", "Yes..");
}

@Override
public void onConnectionFailed(ConnectionResult result) {
    // TODO Auto-generated method stub
    Log.i("connectionFailed", "yes...shit");

}

@Override
public void onConnected(Bundle connectionHint) {
    // TODO Auto-generated method stub
    Log.i("in onConnected", "yes..here");
    /*
     * mGetLocationLocationRequest = LocationRequest.create();
     * mGetLocationLocationRequest
     * .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
     * mGetLocationLocationRequest.setInterval(50);
     * mGetLocationLocationClient
     * .requestLocationUpdates(mGetLocationLocationRequest, this);
     */
}

@Override
public void onDisconnected() {
    // TODO Auto-generated method stub
    Log.i("in onDisconnected", "yes..here");
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Log.i("in btnClick", "yes..");
    if (ok == GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)) {
        Log.i("In googpleplayservice", "Available..");
        mGetLocationLocationClient = new LocationClient(this, this, this);
        mGetLocationLocationClient.connect();
        // mGetLocationcurrentLocation =
        // mGetLocationLocationClient.getLastLocation();
    } else
        // Toast.makeText(getApplicationContext(), "Not..available",
        // Toast.LENGTH_SHORT).show();
        mGetLocationLocationClient.disconnect();

}

Here is my logcat output:

02-23 04:36:06.351: E/Icing(806): Couldn't handle   android.intent.action.PACKAGE_ADDED    intent due to initialization failure.
02-23 04:36:06.401: E/Icing(806): Couldn't handle  android.intent.action.PACKAGE_REPLACED intent due to initialization failure.
02-23 04:37:30.691: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.example.pedometer
02-23 04:37:31.001: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_REMOVED intent due to initialization failure.
02-23 04:37:31.361: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.pedometer
02-23 04:37:31.711: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=com.example.pedometer
02-23 04:37:31.761: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_ADDED intent due to initialization failure.
02-23 04:37:31.781: I/PeopleContactsSync(806): CP2 sync disabled
02-23 04:37:32.341: I/PeopleContactsSync(806): CP2 sync disabled
02-23 04:37:32.411: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_REPLACED intent due to initialization failure.

I am not getting why its showing problem with intent, I am never used it. Please can anyone help me I read many posts but didnt found any answer.

Thanks in advance

My Manifest FIle

 <?xml version="1.0" encoding="utf-8"?> 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.pedometer"
    android:versionCode="1"
   android:versionName="1.0" >

 <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" 
    />
<!-- ACCESS_COURSE_LOCATION FOR RETREIVING LOCATION THROUGH WIFI AND CELL TOWERS 
     ACCESS_FINE_LOCATION FOR RETREIVING LOCATION THROUGH GPS,WIFI,CELL TOWERS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION"/>

  <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppBaseTheme"
     >
     <meta-data android:name="com.google.android.gms.version"
       android:value="@integer/google_play_services_version" />
    <activity
        android:name="com.example.pedometer.MainActivity"
        android:label="@string/app_name" 

        >


        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.pedometer.GetLocation"
        android:label="@string/app_name" 
        />
 </application>

</manifest>
like image 227
user3339691 Avatar asked Feb 23 '14 10:02

user3339691


1 Answers

You have this in your manifest entry for your MainActivity:

<intent-filter>
    <action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>

Why is this here? This is a broadcast Intent and has nothing to do with Activity. If you want to listen for this broadcast Intent you need to do it in a BroadcastReceiver.

Just remove this.

like image 197
David Wasser Avatar answered Oct 16 '22 10:10

David Wasser