Launch activity using custom intent throwing ACTIV

2019-05-29 06:02发布

I am using the below code to launch the activity form my application:

Intent intent = new Intent();
intent.setAction("com.android.excample.cutstom_action");
intent.setData(data); //public Uri data
intent.putExtra(Intent.Extra_stream, stream); // public Uri stream
startActivity(intent);

And in the other application the activity is defined in manifest file as follow:

<activity android:name="MyActivity">
<intent-filter>
<action android:name="com.android.excample.cutstom_action"/>
<category android:name = "android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>

but when i try to start the activity i am getting activity not found exception. please help me to solve this issue

the crash log is as follow: "03-04 20:03:53.351: E/AndroidRuntime(22633): FATAL EXCEPTION: main 03-04 20:03:53.351: E/AndroidRuntime(22633): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.contacts/data/51826 flg=0x1 }} to activity {com.example.test/com.example.test.ContentPickerTester}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.excample.cutstom_action } 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread.deliverResults(ActivityThread.java:2983) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3026) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread.access$1100(ActivityThread.java:126) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1180) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.os.Handler.dispatchMessage(Handler.java:99) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.os.Looper.loop(Looper.java:137) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread.main(ActivityThread.java:4456) 03-04 20:03:53.351: E/AndroidRuntime(22633): at java.lang.reflect.Method.invokeNative(Native Method) 03-04 20:03:53.351: E/AndroidRuntime(22633): at java.lang.reflect.Method.invoke(Method.java:511) 03-04 20:03:53.351: E/AndroidRuntime(22633): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 03-04 20:03:53.351: E/AndroidRuntime(22633): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554) 03-04 20:03:53.351: E/AndroidRuntime(22633): at dalvik.system.NativeStart.main(Native Method) 03-04 20:03:53.351: E/AndroidRuntime(22633): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.excample.cutstom_action } 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.Activity.startActivityForResult(Activity.java:3190) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.Activity.startActivity(Activity.java:3297) 03-04 20:03:53.351: E/AndroidRuntime(22633): at com.example.test.ContentPickerTester.onActivityResult(ContentPickerTester.java:64) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.Activity.dispatchActivityResult(Activity.java:4649) 03-04 20:03:53.351: E/AndroidRuntime(22633): at android.app.ActivityThread.deliverResults(ActivityThread.java:2979)"

1条回答
看我几分像从前
2楼-- · 2019-05-29 06:46

set "." before the name of your activity in the manifast file

".MyActivity"

or set it with the full qualified path like so:

"com.android.excample.MyActivity"
查看更多
登录 后发表回答