从首选项启动intent时的ActivityNotFoundException

jpa*_*ahn -1 android action preferences android-intent

test.class类型是对的吗?如何?我该怎么办?

<Preference 
    android:key="test" 
    android:title="test" 
    android:summary="test"> 
   <intent android:action="test.class" >  <=== **ERROR/AndroidRuntime(2384): android.content.ActivityNotFoundException: No Activity found to handle Intent** 
    </intent>  
</Preference> 
Run Code Online (Sandbox Code Playgroud)

Dan*_*ick 13

我相信问题是询问如何从PreferenceScreen启动活动.这可以使用XML中的以下定义来实现:

<Preference
  android:title="Tap me"
  android:summary="Tap to start activity">
  <intent
     android:action="android.intent.action.VIEW"
     android:targetPackage="com.example"
     android:targetClass="com.example.MyActivityClass" />
</Preference>
Run Code Online (Sandbox Code Playgroud)

最后,确保在清单中定义了Activity.

  • 想对此发表评论.基本上**targetClass**是_full包+ class_,而**targetPackage**是清单中指定的应用程序包,例如:`<manifest xmlns:android ="http://schemas.android. com/apk/res/android"package ="ekawas.blogspot.com"...`**targetPackage**将是:**targetPackage ="ekawas.blogspot.com"** (7认同)