使用自定义操作启动活动 [英] Start Activity Using Custom Action
本文介绍了使用自定义操作启动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用自定义操作在我的应用中启动一项活动.我找到了一些答案,但我尝试的一切都会抛出 java.lang.RuntimeException
说 No Activity found to handle Intent { act=com.example.foo.bar.YOUR_ACTION }.
I am looking to start an activity in my app using a custom action. I have found a few answers but everything I try it throws java.lang.RuntimeException
saying No Activity found to handle Intent { act=com.example.foo.bar.YOUR_ACTION }.
这是我的清单文件中的活动:
This is the activity in my manifest file:
<activity
android:name=".FeedbackActivity" >
<intent-filter>
<action android:name="com.example.foo.bar.YOUR_ACTION" />
</intent-filter>
</activity>
这就是我开始活动的方式:
And this is how I'm starting the activity:
Intent intent = new Intent("com.example.foo.bar.YOUR_ACTION");
startActivity(intent);
任何帮助将不胜感激.
推荐答案
我认为您创建的意图是错误的.试试这个:
I think you are creating your intent wrong. Try like this:
String CUSTOM_ACTION = "com.example.foo.bar.YOUR_ACTION";
//Intent i = new Intent(this, FeedBackActivity.class); // <--- You might need to do it this way.
Intent i = new Intent();
i.setAction(CUSTOM_ACTION);
startActivity(i);
这篇关于使用自定义操作启动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文