Frage

Ich habe eine Tätigkeit, dass ich als Launcher Kategorie erklären kann und es startet einfach gut aus dem Home-Bildschirm. Allerdings, wenn ich versuche, die gleiche Tätigkeit in meine SyncAdapter Einstellungen Aktivität Hook-up und öffnen Sie sich von den Konten & Sync Seite -> MySyncAdapter. -> (Touch-Konto Listing) es bricht mit einem System fatalen Fehlern (neu startet Telefon)

Inzwischen mein SyncAdapter arbeitet anderer Hinsicht.

Hier ist das Protokoll am Punkt des Aufpralls:

01-13 12:31:00.976  5024  5038 I ActivityManager: Starting activity: Intent { act=android.provider.Settings.ACTION_SYNC_SETTINGS flg=0x10000000 cmp=com.myapp.android.syncadapter.ui/SyncAdapterSettingsActivity.class (has extras) }
01-13 12:31:00.985  5024  5038 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
01-13 12:31:00.985  5024  5038 E AndroidRuntime: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.android.syncadapter.ui/SyncAdapterSettingsActivity.class}; have you declared this activity in your AndroidManifest.xml?
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.app.ContextImpl.startActivity(ContextImpl.java:622)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.preference.Preference.performClick(Preference.java:828)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.widget.AdapterView.performItemClick(AdapterView.java:284)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.widget.ListView.performItemClick(ListView.java:3382)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:587)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:92)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:123)
01-13 12:31:00.985  5024  5038 E AndroidRuntime:    at com.android.server.ServerThread.run(SystemServer.java:517)
01-13 12:31:00.985  5024  5038 I Process : Sending signal. PID: 5024 SIG: 9
01-13 12:31:01.005  5019  5019 I Zygote  : Exit zygote because system server (5024) has terminated
01-13 12:31:01.015  1211  1211 E installd: eof

Hier ist ein Ausschnitt aus meiner Manifest-Datei:

   <activity android:name="com.myapp.android.syncadapter.ui.SyncAdapterSettingsActivity"
              android:label="@string/title_settings" 
              android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.provider.Settings.ACTION_SYNC_SETTINGS"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

habe ich vergessen, über die XML-Ressourcendatei (account_preferences.xml), auf die verwiesen wird. Es bietet eine weitere Dereferenzierungsebene Verweis auf den Namen der Aktivität. Ich kann es manipulieren entsprechend den Protokolleintrag zu ändern zu bekommen. Also, ich denke, dass ein Hinweis auf die Lösung. Das Zielpaket und Zielklasse verketteten zusammen, um die Namen der Aktivität zu definieren, zu starten. Was ich im Protokoll aufgefallen ist, dass es ein Schrägstrich (/) im Pfadnamen und ich denke, das ist, warum es nicht in der Lage ist, die Aktivität zu finden. Zum Beispiel, wenn ich nehme die ( .ui ) der Verpackung heraus und es in der Ziel-Aktivität setzen, dann werden die Schrägstrich bewegt sich vor dem .ui in der Pfad.

account_preferences.xml:

 <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="@string/format_auth_preferences" />
    <PreferenceScreen
         android:key="key_syncadapter_auth"
         android:title="@string/key_syncadapter_auth_action"
         android:summary="@string/key_syncadapter_auth_summary">
         <intent
             android:action="android.provider.Settings.ACTION_SYNC_SETTINGS"
             android:targetPackage="com.myapp.android.syncadapter.ui"
             android:targetClass=".SyncAdapterSettingsActivity" />
     </PreferenceScreen>
 </PreferenceScreen>

log Snippet:

01-14 14:34:34.270 E/AndroidRuntime( 6374): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
01-14 14:34:34.270 E/AndroidRuntime( 6374): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.android.syncadapter.ui/.SyncAdapterSettingsActivity}; have you declared this activity in your AndroidManifest.xml?
War es hilfreich?

Lösung

I got it! Basically, the package is the root package and the target class is the fully qualified name.

     <intent
         android:action="android.provider.Settings.ACTION_SYNC_SETTINGS"
         android:targetPackage="com.myapp.android.syncadapter"
         android:targetClass="com.myapp.android.syncadapter.ui.SyncAdapterSettingsActivity" />

I also had to carefully check my AndroidManifest to be certain that the values were correctly spelled so they could match and that I had an intent-filter that was meaningful for the activity to respond to.

Now I have to implement the settings config activity and format the result in an Intent correctly. I sense another question coming from me :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top