2017-10-06 104 views
1

我知道我可以用Intent打开Activity,但我试图从我的应用程序打开特定的活动。如何打开第三方应用程序的特定活动

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

例子: - 我的应用程序是一个我都开设置应用程序B的页这是第三方应用程序,我也知道活动名称。

如何通过意向

+1

解决方案https://stackoverflow.com/a/2210073/1872098和第三方应用程序的活动必须有出口= true在清单 –

+0

最有可能的,这种活动不出口,因此,你可以不启动它。 – CommonsWare

+0

java.lang.SecurityException:Permission Denial:starting Intent我还添加了android:exported =“true” –

回答

0

首先,你需要找出ü要使用意图与ü希望直接从您的应用程序启动活动名称一起启动应用程序的包名打开这个设置页面。

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

java.lang.SecurityException:Permission Denial:starting Intent我还添加了android:exported =“true” –

+0

您启动的活动必须在manifest.xml中声明为android:exported =“true”。否则,你得到了例外 –

相关问题