Ahm*_*lan 33 android preferences android-intent onitemclicklistener android-activity
找不到活动来处理Intent错误?它将如何解决.
Preference customPref = (Preference) findPreference("DataEntryScreen");
customPref
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent i = new Intent("com.scytec.datamobile.vd.gui.android.AppPreferenceActivity");
startActivity(i);
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
Kar*_*hik 45
将以下内容添加到您的清单中:
<activity android:name=".AppPreferenceActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="com.scytec.datamobile.vd.gui.android.AppPreferenceActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
Ahm*_*ail 17
在我的情况下,我确信行动是正确的,但我传递错误的URL,我通过网站链接没有http://在它的开头,所以它引起了同样的问题,这是我的清单(它的一部分) )
<activity
android:name=".MyBrowser"
android:label="MyBrowser Activity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="com.dsociety.activities.MyBrowser" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当我编写以下代码时,在运行时抛出相同的异常:
Intent intent = new Intent();
intent.setAction("com.dsociety.activities.MyBrowser");
intent.setData(Uri.parse("www.google.com")); // should be http://www.google.com
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
一般来说,为了避免这种异常,你需要通过try尝试包围你的代码
try{
// your intent here
} catch (ActivityNotFoundException e) {
// show message to user
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
87358 次 |
| 最近记录: |