我想在另一个应用程序中打开一个应用程序的活动 为此我正在做
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings",
"com.android.settings.audiopreferences.SystemAudioSettings"));
context.startActivity(intent);
如果我执行上面的Im得到以下异常
id=1: thread exiting with uncaught exception (group=0x40fac930)
E/AndroidRuntime( 2741): FATAL EXCEPTION: main
E/AndroidRuntime( 2741): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.settings/.audiopreferences.SystemAudioSettings } from ProcessRecord{414c0b58 2741:com.dea600.radioapp/u0a10071} (pid=2741, uid=10071) not exported from uid 1000
E/AndroidRuntime
答案 0 :(得分:1)
android:exported="true"; // Have to include it in the manifest file - activity to be used across multiple applications
Example
<activity
android:name="com.example1.utility.MainActivity"
android:exported="true"
android:label="@string/app_name" />
Using MAinActivity from Another application
Intent intent = new Intent();
intent.setClassName("com.example.utility", "com.example1.utility.MainActivity");
context.startActivity(intent3);
答案 1 :(得分:0)
您正在尝试从系统中打开设置活动。您将有更好的机会使用实际的&#34;动作&#34;对于那项活动。 试试
context.startActivity(new Intent("android.settings.SOUND_SETTINGS"));
答案 2 :(得分:0)
试试这个
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);