【问题标题】:How to open particular activity of 3rd party application [duplicate]如何打开第 3 方应用程序的特定活动 [重复]
【发布时间】:2017-10-06 12:42:15
【问题描述】:

我知道我可以使用 Intent 打开 Activity,但我正在尝试从我的应用程序中打开特定的 Activity。

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.3rdPartyApplcation");
if (launchIntent != null) 
{
     startActivity(launchIntent);
}

示例:- 我的应用程序是 A 我必须打开应用程序 B 的 设置页面,它是 3rd 方应用程序,我也知道活动名称。

如何通过意图打开此设置页面

【问题讨论】:

  • solution stackoverflow.com/a/2210073/1872098 和第三方应用程序活动必须在清单中导出 = true
  • 很可能,该活动未导出,因此您无法启动它。
  • java.lang.SecurityException: Permission Denial: starting Intent 我还添加了 android:exported="true"

标签: android android-intent


【解决方案1】:

首先,您需要找出您想要使用 Intent 启动的应用程序的包名称以及您想要直接从您的应用程序启动的活动名称。

 Intent intent=new Intent();
 intent.setComponent(new ComponentName("com.3rdPartyApplcation.packagename", "com.3rdPartyApplcation.packagename.SettingsActivity"));
 startActivity(intent);

【讨论】:

  • java.lang.SecurityException: Permission Denial: starting Intent 我还添加了 android:exported="true"
  • 你启动的activity必须在manifest.xml中声明为android:exported="true"。否则你得到了例外
猜你喜欢
  • 1970-01-01
  • 2017-06-03
  • 2012-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多