Any idea what would be intent to launch application specific Data usage settings to enable/disable Restrict Background Data.
To launch general setting screen following is the post i referred and it worked also
Which Intent for Settings - Data usage
But I need to launch for specific package id.
Please check this launch screen
This screen is for Gmail
Looking for an intent with parameters to launch this screen programmatically.
Any help is appreciated.
Try using this:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings",
"com.android.settings.Settings$DataUsageSummaryActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Related
I am using the code to call an intent in Android
Intent intent = new Intent();
String PACKAGE_NAME="com...."
intent.setPackage(PACKAGE_NAME);
intent.setAction(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getApplication().startActivity(intent);
Unfortunately, in some case, I do not know the PACKAGE_NAME. So, another method is using broadcast. How can I use it? Thanks all
You cant call Activity directly if you dont know package and name of that Activity.
Since you dont know package and Activity name you can only ask OS to show all possible variants for your Intent Action. In most cases user click "always open this app for this action" what means that you will directly open another app.
So in your case your code should looks like
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
//dont forget to check if user has at least one application for your Intent Action
if (intent.resolveActivity(getPackageManager()) != null) {
context.startActivity(intent);
}
Is there any way to, in my app, to redirect a user to a specific settings 'page'? My app works as a lock screen app, so I want to be able to redirect the user directly to the "Lock Screen" section of the Android settings. (Preferably via a button or something similar)
ACTION_SECURITY_SETTINGS Intent:
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
For complete Settings Intents
I managed to find the correct answer in an old Stackoverflow-post from a while back. The code snippet now looks like this:
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
val intent = Intent(Settings.ACTION_SECURITY_SETTINGS)
intent.flags =
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(intent)
Note the flags. These are optional, but necessary to remove the previous settings screen from the screen if it was previously open (this is needed if your application wants to open multiple settings screens).
I have an application in which I want to show a custom activity(Access Denied) when user try to share an image.
When I am trying to share an image from default 'Downloads' application (For eg: share image through default message/gmail application) the custom activity is showed and exits 'Downloads' application.But next time when I launch the 'Downloads' application and press on an image the previously created draft mail/message is shown as the top activity.So it shows the custom activity always.
Launched the 'Downloads' application by using this intent.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packagename,className));
startActivity(intent);
How can I fix this? I want to launch the 'Downloads' application as new (removing history of gmail/message etc.) every time.
Please try below code
Intent intent = new Intent(ClassA.this, ClassB.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
i am starting the browser with intent using
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(i);
but when i see recent applications i see
Internet
before my Application.
I dont want Internet to be shown at all in recent when i launch it as sub-application of mine.
Is there a flag to do so??
thanks.
use Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS with your intent
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
I encounter this flag - FLAG_ACTIVITY_RESET_TASK_IF_NEEDED paired with FLAG_NEW_TASK.
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.applicationA", "com.applicationA.Activity1"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intent);
This was in the following context:
1. The browser application recognized a phone number.
2. User can long press it and get a context menu with a "dial" option.
3. the browser then fires the above intent to open the dialer.
I have read the documentation for this flags over and over again, and tried playing with it, changing the activities affinities and still have no clue as to what should be the expected behavior here.
Any help is appreciated.