用行动开始活动,但没有类别 [英] Start Activity with action, but no category

查看:105
本文介绍了用行动开始活动,但没有类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图启动其他APK定义的活动,在AndroidManifest.xml中,它定义了一个活动,并与一个动作,但没有定义的类别。

I am trying to start an activity defined in another apk, in its AndroidManifest.xml, it defines an activity and with an action, but no category defined.

该格式是这样

<activity name="...">
    <intent-filter>
        <action android:name="action name">
    <intent-filter>
</activity>

我的code是继

My code is following

Intent i = new Intent("action name");
startActivity(i);

不过我的APK与未捕获的异常ActivityNotFound坠毁,日志阅读
无活动处理的意图......

However my apk crashed with uncaught ActivityNotFound exception, the logs read No Activity found to handle intent ... "

有什么想法?

感谢名单了很多。

推荐答案

纵观意向文档,它说,在这里提供的注意也是默认类别:这是必需的 Context.startActivity 的方法来解决您的活动时未明确指定其组件名称如果该活动的IntentFilter的定义并不包括这一类,那么你不能用startActivity启动。尝试使用setClassName方法,并把它传递的包类和你想开始练习类。

Looking at the Intent documentation, it says Note also the DEFAULT category supplied here: this is required for the Context.startActivity method to resolve your activity when its component name is not explicitly specified. If the activity's IntentFilter definition does not include that category then you can't start it with startActivity. Try using the setClassName method, and pass it the package class and the activity class you're trying to launch.

这篇关于用行动开始活动,但没有类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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