這是一個非常基本的問題,但我無法弄清楚。我想製作一個自定義意向選擇器。當我運行選擇器意圖時,它崩潰。當我用ACTION_VIEW運行intent時,它完美地工作。它向我展示了仿真器選擇器中的系統構建,當我選擇瀏覽器時,它開啓了Uri。意圖選擇器無法找到應用程序
的ErrorMessage:
09-11 11:06:30.057 6070-6070/? D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
09-11 11:06:30.088 6070-6070/course.labs.intentslab D/dalvikvm﹕ GC_FOR_ALLOC freed 164K, 18% free 2795K/3404K, paused 1ms, total 3ms
09-11 11:06:30.138 6070-6070/course.labs.intentslab D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
09-11 11:06:30.138 6070-6070/course.labs.intentslab D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
09-11 11:06:30.138 6070-6070/course.labs.intentslab D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
09-11 11:06:30.138 6070-6070/course.labs.intentslab D/﹕ HostConnection::get() New Host Connection established 0xb9579ef0, tid 6070
09-11 11:06:30.189 6070-6070/course.labs.intentslab W/EGL_emulation﹕ eglSurfaceAttrib not implemented
09-11 11:06:30.189 6070-6070/course.labs.intentslab D/OpenGLRenderer﹕ Enabling debug mode 0
09-11 11:06:31.807 6070-6070/course.labs.intentslab I/Lab-Intents﹕ Entered startImplicitActivation()
09-11 11:06:31.807 6070-6070/course.labs.intentslab I/Lab-Intents﹕ Chooser Intent Action:android.intent.action.CHOOSER
09-11 11:06:31.988 6070-6070/course.labs.intentslab W/ChooseActivity﹕ Target is not an intent: null
09-11 11:06:31.988 6070-6070/course.labs.intentslab D/AndroidRuntime﹕ Shutting down VM
09-11 11:06:31.988 6070-6070/course.labs.intentslab W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb181c678)
09-11 11:06:31.988 6070-6070/course.labs.intentslab E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.app.SuperNotCalledException: Activity {android/com.android.internal.app.ChooserActivity} did not call through to super.onCreate()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2177)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
的Java功能:
private void startImplicitActivation() {
Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
Intent chooserIntent = new Intent();
chooserIntent.createChooser(baseIntent, "Open Browser...");
startActivity(chooserIntent);
}
ChooserActivity.java(這是我ChooserActivity.java在SDK路徑發現我無法弄清楚如何我發現,文件在Android Studio中。
package com.android.internal.app;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
public class ChooserActivity extends ResolverActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (!(targetParcelable instanceof Intent)) {
Log.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
finish();
return;
}
Intent target = (Intent)targetParcelable;
CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
if (title == null) {
title = getResources().getText(com.android.internal.R.string.chooseActivity);
}
Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
Intent[] initialIntents = null;
if (pa != null) {
initialIntents = new Intent[pa.length];
for (int i=0; i<pa.length; i++) {
if (!(pa[i] instanceof Intent)) {
Log.w("ChooseActivity", "Initial intent #" + i
+ " not an Intent: " + pa[i]);
finish();
return;
}
initialIntents[i] = (Intent)pa[i];
}
}
super.onCreate(savedInstanceState, target, title, initialIntents, null, false);
}
}
更新:再次嘗試後,它顯示了我不同的錯誤我ssage。也許這有幫助。
09-11 13:07:00.900 21068-21068/course.labs.intentslab D/﹕ HostConnection::get() New Host Connection established 0xb8064840, tid 21068
09-11 13:07:00.970 21068-21068/course.labs.intentslab W/EGL_emulation﹕ eglSurfaceAttrib not implemented
09-11 13:07:00.970 21068-21068/course.labs.intentslab D/OpenGLRenderer﹕ Enabling debug mode 0
09-11 13:07:03.120 21068-21068/course.labs.intentslab I/Lab-Intents﹕ Entered startImplicitActivation()
09-11 13:07:03.120 21068-21068/course.labs.intentslab I/Lab-Intents﹕ Chooser Intent Action:null
09-11 13:07:03.120 21068-21068/course.labs.intentslab D/AndroidRuntime﹕ Shutting down VM
09-11 13:07:03.120 21068-21068/course.labs.intentslab W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb17b5678)
09-11 13:07:03.120 21068-21068/course.labs.intentslab E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent { }
錯誤似乎是在android框架內(好吧,有...他們在super.onCreate()之前調用finish()),但僅限於**,如果您將null作爲目標意圖傳遞......您沒有提供您使用的真實代碼,因爲此代碼不會導致此類行爲 – Selvin
您還需要其他哪些代碼?我可以爲您提供一切:D – Johnny
我不需要任何代碼... **現在,我不想解決您的問題** ...當我試圖找出爲什麼錯誤是從android的framwork,現在它是另一個noob的錯誤(顯然,你將baseIntent設置爲null或某個範圍問題) – Selvin