2017-10-06 130 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」。否則,你得到了例外 –

相關問題