android中如何在一个app中启动另外一个app中指定的Activity

zclever 2011-08-03 10:42:49
有两个app,分别叫做App1和App2。App1包含两个Activity,分别叫做App1_A和App1_B.其中App1_A是入口Activity.
App2只有一个Activity,叫做App2_A。
现在在App2_A中通过startActivity启动App1_A是没问题的.但是启动App1_B的时候报了fc错误。logcat如下:
08-03 02:23:44.119: WARN/ActivityManager(64): Permission denied: checkComponentPermission() reqUid=10030
08-03 02:23:44.119: WARN/ActivityManager(64): Permission Denial: starting Intent { act=android.intent.action.VIEW cmp=com.hello/.activity2 } from ProcessRecord{407c8bc8 665:com.fileExplorer/10032} (pid=665, uid=10032) requires null

...全文
1494 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sAGiTTaR 2011-08-03
  • 打赏
  • 举报
回复
即使直接指定了目标activity的ComponentName,跨应用的activity调用也要至少给目标activity指定一个带action的filter。如:
<intent-filter>
<action android:name="" />
</intent-filter>
action name为空即可。
yongyuandeni 2011-08-03
  • 打赏
  • 举报
回复
通过隐式intent调用方法实现,需要在被调用的activity的manifest文件中添加
<intent-filter>
<action android:name="com.example.project.SHOW_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

在StartActivity(it)之前,设定该intent对应的action(com.example.project.SHOW_ACTIVITY)
zclever 2011-08-03
  • 打赏
  • 举报
回复

Intent intent = new Intent();
ComponentName componentName = new ComponentName("com.hello","com.hello.App1_A");//这个没问题
//ComponentName componentName = new ComponentName("com.hello","com.hello.App1_B");//这个报错
intent.setComponent(componentName);
startActivity(intent);
zclever 2011-08-03
  • 打赏
  • 举报
回复
揭帖。散分

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧