I want to open an activity of one application inside another application
for that I am doing
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings",
"com.android.settings.audiopreferences.SystemAudioSettings"));
context.startActivity(intent);
if i execute above Im getting the below Exception
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
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);
You're trying to open a settings activity from the system. You'll have a better chance of using the actual "action" for that activity.
Try
context.startActivity(new Intent("android.settings.SOUND_SETTINGS"));
Try this
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
Related
I'm trying to launch an external shortcut, What i have is only the activity path .
Here's what i did :
try {
view.getContext().startActivity(Intent.getIntentOld(List.getShortcutPath());
} catch (URISyntaxException e) {
e.printStackTrace();
}
Log :
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=com.sonyericsson.music.ArtistShortcutActivity }
The Path I'm trying to launch :
com.sonyericsson.music.ArtistShortcutActivity
How to launch the shortcut ?
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
startActivity(intent);
if you get permission denial error, then add android:exported XML attribute is true in the manifest for the activity you want to launch
Here com.example is the package name of the app your activity that you want to launch is in, and com.example.myexampleactivity the full name of the activity you want to launch
If the intended activity to launch is package private, then you wont be able to launch it from a foreign application activity. This is done for security reasons by Google
I am trying to call VoiceListActivity of VoiceRecorder from my app on samsung S4 but I get following error
08-27 09:35:03.401: E/AndroidRuntime(17313): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.RUN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.sec.android.app.voicerecorder/.VoiceListActivity } from ProcessRecord{449e11c8 17313:com.example.ui_sha/u0a205} (pid=17313, uid=10205) not exported from uid 10193
my code :
Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(ComponentName.unflattenFromString("com.sec.android.app.voicerecorder/com.sec.android.app.voicerecorder.VoiceListActivity"));
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
So my question is :
Can i use Intent to call VoiceListActivity from my app? If yes, How I have to do ?
If no, can you show me another way to call it ?
Solution :
I asked some body to solve this problem but it is impossible when code in VoiceList's manifest have android:exported = true. So the only solution is you need to build your own VoiceListActivity and its screen. It could be take some time but it is only solution.
I want to open an subactivity of one application inside another application for that I am doing
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings",
"com.android.settings.audiopreferences.SystemAudioSettings"));
context.startActivity(intent);
Inside Android Manifest File:
<activity
android:name="com.android.settings.audiopreferences.SystemAudioSettings"
android:exported="true"
android:label="SystemAudioSettings">
</activity>
if i execute above Im getting the below Exception
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
You need to set intent filter for you activity.
See this answer.
When I open a link inside the Facebook app, it opens a new task for the browser while I can switch back to the Facebook app instead of opening the browser inside itself like an ordinary Activity. But when I launch an Intent to my application's Google Play page it behaves like an Activity inside my app instead of launching a separate instance for Google Play.
Here's how I'm starting the Intent:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=MY.APP.PACKAGE")));
I found this thread and wrote this snippet:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("market://details?id=MY.APP.PACKAGE"));
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Which fails with this message in logcat:
04-29 12:35:42.681: E/AndroidRuntime(8482): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.LAUNCHER] dat=market://details?id=MY.APP.PACKAGE flg=0x50000000 }
Any ideas?
You just need to remove the addCategory() call and it should work.
I try to start an activity from another package, but it has not LAUNCHER category
Intent i = new Intent();
i.setComponent(new ComponentName(maxVerPackageName, maxVerClassName));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
I faced the Exception: "An exception occurred: java.lang.SecurityException"
what's wrong, please help?
The other activity is enforcing a permission. So that only apps that have the permission or same uid can launch the activity.
Edit: If you have written other app
then add this attribute to the other activity which you are trying to launch
android:exported="true"