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.
Related
I'm trying to launch Deskclock app from a different application using below code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setComponent(new ComponentName("com.android.deskclock","com.android.deskclock.DeskClock"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
And I see below error:
AndroidRuntime: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.deskclock/com.android.deskclock.DeskClock}; have you declared this activity in your AndroidManifest.xml?
Why should i declare Deskclock activity in my application?
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 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);
I get an error when launching an activity from a fragment, using an intent.
Intent intent = new Intent(this.getActivity(),FormActivity.class);
intent.putExtra("Horas",hours);
intent.putExtra("Minutos",minutes);
intent.putExtra("Segundos",seconds);
intent.putExtra("Fecha",date);
intent.putExtra("Hora",time);
startActivity(intent);
LogCat:
android.content.ActivityNotFoundException: Unable to find explicit activity class
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1719)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1491)
at android.app.Activity.startActivityForResult(Activity.java:3436)
at android.app.Activity.startActivityForResult(Activity.java:3393)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:848)
at android.support.v4.app.Fragment.startActivity(Fragment.java:878)
at es.timetrack.app.InActivityPageFragment.onClick(InActivityPageFragment.java:148)
Declare the Activity you are starting in the Manifest .xml file:
<activity
android:name="your.package.FormActivity"
android:label="FormActivity" />
Some additional information:
The App Manifest
There you can see the structure of the manifest.xml file and what it is used for.
In addition to you not declaring your Activity in the manifest file, your application might crash due to unhandled exceptions in the onCreate(...) method of your FormActivity.
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"