启动活动使用自定义操作 [英] Start Activity Using Custom Action

查看:88
本文介绍了启动活动使用自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找使用自定义操作,开始在我的应用程序的活动。我已经找到了一些答案,但一切我尝试它抛出 java.lang.RuntimeException的说无活动处理意向{行为= 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);

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

推荐答案

我觉得你创建你的意图是错误的。尝试是这样的:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆