2014-02-23 2 views
6

Ich erstelle MainActivity Klasse implementieren LocationListener, GooglePlayServicesClient, um den aktuellen Standort mit FusedLocationApi zu erhalten. Es zeigt mir einige seltsame Fehler, aber das stürzt meine App nicht ab, aber die Funktionalität funktioniert nicht. Ich setze Log.i(), um zu überprüfen, ob die Kontrolle die überschriebenen Methoden eingibt, aber es scheint, dass die Kontrolle nicht in diese Methoden eingeht. Unten ist der Code und die Ausgabe. Bitte helfenKonnte den Fehler android.intent.package_ADDED und REMOVED Fehler beim Abrufen des Standorts mit Fused Location API nicht lösen

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(); 

} 

Hier meine logcat Ausgabe lautet:

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. 

ich immer bin nicht, warum mit der Absicht, seine zeigt Problem, ich bin noch nie benutzt. Bitte kann mir jemand helfen Ich habe viele Beiträge gelesen aber keine Antwort gefunden.

Vielen Dank im Voraus

Mein Manifest-Datei

<?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> 
+0

dank donfuxx für was darauf hindeutet, eigentlich: Ich bin auf Stack-Überlauf posten – user3339691

+0

Manifest –

+0

hinzugefügt haben manifest David Wasser – user3339691

Antwort

1

Sie haben dies in Ihrem Manifest Eintrag für Ihre MainActivity:

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

Warum ist hier das? Dies ist eine Broadcast-Absicht und hat nichts mit Activity zu tun. Wenn Sie auf diese Sendung hören möchten, müssen Sie dies in einer BroadcastReceiver tun.

Entfernen Sie dies einfach.

+0

Dank für die ur-Hilfe Post – user3339691

Verwandte Themen