La mia PreferenceActivity non viene visualizzata, anche se è nel mio file manifesto

Quindi sto modificando l'esempio Cube live wallpaper. Ho una class che estende PreferenceActivity e ho aggiunto l'attività nel mio file manifesto. Continuo a ricevere ActivityNotFoundExceptions.

Ecco la mia class di preferenza:

  • Imansible utilizzare 'questo' in context statico
  • Come app WhiteList in modalità Doze Android 6.0
  • Utilizzo di Android AccountManager per l'authentication degli utenti di un server
  • Facebook Like button nell'applicazione Android
  • Android ha impostato la gravità di un TextView in modo programmato
  • Errore durante l'innalzamento della class com.google.android.youtube.player.YouTubePlayerView nell'adattatore di elenco
  • package com.ptwallpapers.mywallpaper; import com.ptwallpapers.mywallpaper.R; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceActivity; public class MySettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); getPreferenceManager().setSharedPreferencesName( ParticleCandy.SHARED_PREFS_NAME); addPreferencesFromResource(R.xml.settings); getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener( this); } @Override protected void onResume() { super.onResume(); } @Override protected void onDestroy() { getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener( this); super.onDestroy(); } public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { } 

    }

    E qui è il mio file manifesto

     <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ptwallpapers.mywallpaper" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <service android:label="@string/app_name" android:name=".MyWallpaper" android:permission="android.permission.BIND_WALLPAPER" > <intent-filter> <action android:name="android.service.wallpaper.WallpaperService"> </action> </intent-filter> <meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper_info" /> </service> <activity android:label="@string/settings_title" android:name=".MySettingsActivity" android:theme="@android:style/Theme.Light.WallpaperSettings" android:exported="true"> </activity> </application> <uses-sdk android:minSdkVersion="7" /> <uses-feature android:name="android.software.live_wallpaper" /> </manifest> 

    Qualche idea di perché l'attività delle mie preferenze non si legge dal manifesto? Il servizio di carta da parati, MyWallpaper si presenta perfettamente, ma DDMS continua a dirmi l'attività che MySettingsActivity non esce.

    Ecco l'output di logcat

     04-11 00:22:19.617: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) } 04-11 00:22:21.796: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2111 ms (total 2111 ms) 04-11 00:22:25.667: DEBUG/dalvikvm(375): GC freed 4745 objects / 316576 bytes in 192ms 04-11 00:22:25.727: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.ptwallpapers.mywallpaper/MySettingsActivity (has extras) } 04-11 00:22:25.757: DEBUG/AndroidRuntime(375): Shutting down VM 04-11 00:22:25.768: WARN/dalvikvm(375): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 04-11 00:22:25.787: ERROR/AndroidRuntime(375): Uncaught handler: thread main exiting due to uncaught exception 04-11 00:22:25.847: ERROR/AndroidRuntime(375): java.lang.IllegalStateException: Could not execute method of the activity 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2031) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.performClick(View.java:2364) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.onTouchEvent(View.java:4179) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.widget.TextView.onTouchEvent(TextView.java:6540) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.dispatchTouchEvent(View.java:3709) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4363) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2026) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 20 more 04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.ptwallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml? 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivityForResult(Activity.java:2749) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivity(Activity.java:2855) 04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 24 more 04-11 00:22:25.917: INFO/Process(57): Sending signal. PID: 375 SIG: 3 04-11 00:22:25.917: INFO/dalvikvm(375): threadid=7: reacting to signal 3 04-11 00:22:25.988: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin 04-11 00:22:26.012: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes 04-11 00:22:26.044: INFO/dalvikvm(375): Wrote stack trace to '/data/anr/traces.txt' 04-11 00:22:29.307: INFO/Process(375): Sending signal. PID: 375 SIG: 9 04-11 00:22:29.516: INFO/ActivityManager(57): Process android.process.acore (pid 375) has died. 04-11 00:22:29.516: INFO/WindowManager(57): WIN DEATH: Window{44dd50d8 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false} 04-11 00:22:29.576: INFO/WindowManager(57): WIN DEATH: Window{44d660f8 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false} 04-11 00:22:29.586: INFO/WindowManager(57): WIN DEATH: Window{44dbe2f0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false} 04-11 00:22:29.876: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=421 uid=10022 gids={} 04-11 00:22:30.687: DEBUG/ddm-heap(421): Got feature list request 04-11 00:22:30.957: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker 04-11 00:22:31.756: WARN/ResourceType(421): getEntry failing because entryIndex 2 is beyond type entryCount 2 04-11 00:22:31.768: WARN/ResourceType(421): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001 04-11 00:22:32.758: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 375 uid 10022 04-11 00:22:33.137: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3430 ms (total 3430 ms) 04-11 00:22:33.528: ERROR/gralloc(57): [unregister] handle 0x467ae8 still locked (state=40000001) 04-11 00:22:38.368: DEBUG/dalvikvm(364): GC freed 611 objects / 51656 bytes in 179ms 

    Aggiornato logcat

     04-11 01:10:52.976: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) } 04-11 01:10:53.668: WARN/InputManagerService(57): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44db02f8 04-11 01:10:54.587: INFO/ActivityManager(57): Displayed activity android/com.android.internal.app.ChooserActivity: 1140 ms (total 17760 ms) 04-11 01:10:56.458: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.wallpaper.livepicker/.LiveWallpaperListActivity } 04-11 01:10:57.466: DEBUG/dalvikvm(1622): GC freed 1487 objects / 106648 bytes in 167ms 04-11 01:10:57.556: WARN/ResourceType(1622): getEntry failing because entryIndex 2 is beyond type entryCount 2 04-11 01:10:57.587: WARN/ResourceType(1622): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001 04-11 01:10:58.516: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 1625 ms (total 1625 ms) 04-11 01:11:00.717: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) } 04-11 01:11:02.948: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2187 ms (total 2187 ms) 04-11 01:11:11.538: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.ptwallpapers.mywallpaper/MySettingsActivity (has extras) } 04-11 01:11:11.577: DEBUG/AndroidRuntime(1622): Shutting down VM 04-11 01:11:11.587: WARN/dalvikvm(1622): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 04-11 01:11:11.597: ERROR/AndroidRuntime(1622): Uncaught handler: thread main exiting due to uncaught exception 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): java.lang.IllegalStateException: Could not execute method of the activity 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2031) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.performClick(View.java:2364) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.onTouchEvent(View.java:4179) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.widget.TextView.onTouchEvent(TextView.java:6540) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.dispatchTouchEvent(View.java:3709) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Handler.dispatchMessage(Handler.java:99) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Looper.loop(Looper.java:123) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.ActivityThread.main(ActivityThread.java:4363) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at dalvik.system.NativeStart.main(Native Method) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: java.lang.reflect.InvocationTargetException 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2026) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 20 more 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.ptwallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml? 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivityForResult(Activity.java:2749) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivity(Activity.java:2855) 04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 24 more 04-11 01:11:11.748: INFO/Process(57): Sending signal. PID: 1622 SIG: 3 04-11 01:11:11.748: INFO/dalvikvm(1622): threadid=7: reacting to signal 3 04-11 01:11:11.827: INFO/dalvikvm(1622): Wrote stack trace to '/data/anr/traces.txt' 04-11 01:11:11.858: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin 04-11 01:11:11.877: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes 04-11 01:11:13.788: DEBUG/dalvikvm(101): GC freed 3389 objects / 203632 bytes in 2805ms 04-11 01:11:16.787: INFO/Process(1622): Sending signal. PID: 1622 SIG: 9 04-11 01:11:17.037: INFO/ActivityManager(57): Process android.process.acore (pid 1622) has died. 04-11 01:11:17.046: INFO/WindowManager(57): WIN DEATH: Window{44db47b0 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false} 04-11 01:11:17.107: INFO/WindowManager(57): WIN DEATH: Window{44db7138 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false} 04-11 01:11:17.208: INFO/WindowManager(57): WIN DEATH: Window{44da6860 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false} 04-11 01:11:17.426: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=1647 uid=10022 gids={} 04-11 01:11:18.266: DEBUG/dalvikvm(30): GC freed 222 objects / 8512 bytes in 799ms 04-11 01:11:18.577: DEBUG/ddm-heap(1647): Got feature list request 04-11 01:11:18.686: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 406ms 04-11 01:11:19.037: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker 04-11 01:11:19.367: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 652ms 04-11 01:11:19.827: WARN/ResourceType(1647): getEntry failing because entryIndex 2 is beyond type entryCount 2 04-11 01:11:19.837: WARN/ResourceType(1647): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001 04-11 01:11:20.378: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 1622 uid 10022 04-11 01:11:20.737: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3496 ms (total 3496 ms) 04-11 01:11:21.117: ERROR/gralloc(57): [unregister] handle 0x448168 still locked (state=40000001) 04-11 01:23:24.496: DEBUG/dalvikvm(98): GC freed 12398 objects / 575024 bytes in 213ms 

  • C'è un evento da rilevare quando lo schermo si riduce?
  • Vedere l'attività Android recente eseguita dall'utente
  • Sovrascrivi l'animation per notifyItemChanged in RecyclerView.Adapter
  • ICS Android abilita i programmi GPS in modo programmato?
  • Effetti della camera Android non funziona
  • Ottenere il punto di galleggiamento dell'hardware con l'android NDK
  • 4 Solutions collect form web for “La mia PreferenceActivity non viene visualizzata, anche se è nel mio file manifesto”

    Capito. Era il xml della carta da parati che si riferisce nel manifesto, sotto il tag metadata nel tag di servizio. Fondamentalmente, quel xml ha

     <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="MySettingsActivity"/> 

    Avverti la "MySettingsActivity" lì? Sì, dato che questo è un file separato dal manifesto, non ha automaticamente un pacchetto che inizia a cercare i nomi delle classi da. Quindi tutto quello che wherevo fare era mettere il path completo del pacchetto, come così

     <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="com.ptwallpapers.mywallpaper.MySettingsActivity" /> 

    e voila! Il mio schermo di preferenza si apre ora quando ho colpito il button Impostazioni … invece che l'arresto della forza. Oh uomo, faccia a faccia !

    Vorrei aggiungere un punto principale sul tuo android:name attributi di android:name (ad esempio, android:name=".MySettingsActivity" ) o completamente qualificare il loro pacchetto (ad esempio, android:name="com.ptwallpapers.mywallpaper.MySettingsActivity" ).

    Inoltre, import com.ptwallpapers.mywallpaper.R l' import com.ptwallpapers.mywallpaper.R , in quanto non dovrebbe essere necessaria (si è già in quel pacchetto) e potrebbe essere la maschera di un problema di pacchetto.

    Se nessuno di questi aiuti, aggiornare la tua domanda per spiegare where, esattamente, hai ottenuto ActivityNotFoundExceptions .

    Prima risposta cioè aggiungere

    è corretta. questo dovrebbe essere aggiunto nel file xml che descrive il tag.

    se si desidera eliminare l'impatto delle impostazioni, eliminare l'android: settingActivity tag dallo stesso file.

    n njy la bellezza della carta da parati dal vivo ..

    gli applausi, Shivam Sabhlok, India

    Assicurarsi che il tuo MySettingsActivity sia nel pacchetto com.ptwallpapers.mywallpaper , altrimenti devi specificare il nome del pacchetto assoluto.

    L'Android è un fan Android di Google, tutto su telefoni Android, Android Wear, Android Dev e applicazioni Android Games e così via.