On the first boot itself, I want to set the default browser from the three that are already installed on the system. I do not want to give the user the option to select the default browser, I want to set it for him/her.
How do I go about it?
EDIT : The Phone is running ICS.
It is impossible to do. There is no API method which would allow this.
To do it on first boot make one receiver,whenever boot detects on that time call any activity and on activity onCreate method write this
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.google.android.browser","com.google.android.browser.BrowserActivity"));
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try
{
startActivity(intent);
}
catch (Exception e)
{
e.printStackTrace();
}
This can be done if u develop your own firmware and make it a default app for internet uses.This requires the both firmware and boot permissions from the device to make ur application as the default application.
Any way you can set ur application as always to open the web pages in settings
Related
I'm looking for a way to open a browser at a specific link automatically at a give time / daily.
Maybe there is some kind of script, add-on for bowser but I still haven't find one.
Does anyone know a good solution?
I suggest you to use an AalarmManager here is an example
And then here is the code you should execute
String urlString = "your_url";
Intent intent = new
Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
context.startActivity(intent);
}
catch (ActivityNotFoundException ex) {
context.startActivity(intent);
}
Seems to me this is a combination of three things, setting the alarm, firing the intent and making sure the intent has the data to open a specific uri in the browser.
start activity from an alarm
open a uri
I'm having troubles opening system DND preferences from my App so that user can create or edit Automatic Time rule.
Current situation
Our app already has a similar feature which disables App-notification LED, sound and vibration for some specific time period (for example between 10pm-8am) and is applied app-wide. As of Android Oreo, our feature doesn't work anymore because of Notification Channels. The only solution is, as far as I understand, to create in System preferences Automatic Time rule which is then applied system-wide.
What I want to do?
Just to redirect Oreo user from my app to System preferences ie. Do Not Disturb preferences in order to add or edit Time rule.
The problem
There is no specific Intent which opens Do Not Disturb preferences. The closest one I could find was Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS which leads me to this Preference screen. I also found action which I exactly need, but as you can see, it is hidden by annotation.
Does this mean there is no way to open this Preference screen and I should use another approach?
I also had this question for a long time, now I finally found the solution that works for me:
Java
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$ZenModeSettingsActivity"));
startActivity(intent);
Kotlin
val intent = Intent()
intent.component = ComponentName("com.android.settings", "com.android.settings.Settings\$ZenModeSettingsActivity")
startActivity(intent)
If you take a look at the AndroidManifest.xml for the Settings app you can see that there is an Activity Settings$ZenModeSettingsActivity (as mentioned by #cyb3rko in https://stackoverflow.com/a/63713587/467650) already from Android 5.0.
To send the user to the "Do not disturb" screen you can use the action android.settings.ZEN_MODE_SETTINGS like this:
try {
startActivity(new Intent("android.settings.ZEN_MODE_SETTINGS"));
} catch (ActivityNotFoundException e) {
// TODO: Handle activity not found
}
I would expect the intent filter to be even more stable than the class name.
I have an android application that requires VPN. My users will be using Galaxy Note 3's and will be using the built in "VPN Client" (com.ipsec.vpnclient). I need to find a way to launch this application from my application, in the instance of the VPN dropping. I've already figured out a way to determine if the VPN dropped, but I still need a way to launch the application.
ANSWER:
Thanks to help from #Muthu I was able to get it working with the following method.
final Intent intent = new Intent("android.intent.action.VIEW");
intent.setComponent(new ComponentName("com.ipsec.vpnclient", "com.ipsec.vpnclient.MainActivity"));
EDIT:
To add to the confusion, I am easily able to add a shortcut to the activity (com.ipsec.vpnclient.MainActivity) via another Launcher like ADW or Nova. I also tried using com.ipsec.vpnclient.MainActivity instead of com.ipsec.vpnclient in the method below, to no avail.
Intent intent = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The above method works with other packages, but I can't seem to get this one to launch.
Here is the application when viewed in Android System Info.
Any ideas on how to launch this application programmatically?
You can Start any installed application by using intent. in your case like this
Intent LaunchVPN = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
startActivity( LaunchVPN );
Edit
You can open pre installed apps that can be found inside settings page by
final Intent i = new Intent("android.intent.action.VIEW");
i.setComponent(new ComponentName("com.android.settings","com.android.settings.InstalledAppDetails"));
startActivity(i);
When running this
String ussdCode = "*" + "100" + Uri.encode("#");
startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));
I expect a normal phone call to be done, but instead of that Skype go to front and make the call for *100# USSD code. I logged out from Skype and it sill brings Skype to front!.
How to force it to use the normal phone call instead of Skype?
Thats because you have Skype as the default application for calls. This is a device configuration. You can change it, but note that if you does, it will actualy change that configation, so skype wont be the default any more in your mobile.
You can clear the default application calling this form your activity
getPackageManager().clearPackagePreferredActivities(PACKAGENAME);
the package name of skype is com.skype.raider, so in your case you call this
getPackageManager().clearPackagePreferredActivities("com.skype.raider");
of course you call it before you call the startActivity
UPDATE
I remembered that if you don't want to reset default configuration, you can try to force one app to handle the intent you are sending to startActivity. But you have a problem, you will have to know the package name of the application, and the activity which should handle it. In some cases that will be easy to find out, but in some other it wont. I've been googling for this information for the default android dialer, and also looked in my device, but i didn't find anything. Anyways, if you can find it, you can use the code below and it will be much better since it doesn't change any setting. Also you can remember it since it could be handy in other situations:
Intent intent = new Intent();
intent.setComponent(new ComponentName("PACKAGE_NAME","PACKAGENAME.ACTIVITY_NAME"));
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try
{
startActivity(intent);
}
catch (Exception e)
{
e.printStackTrace();
}
In my application, I've developed to get a list of third party applications that the user installed. from that, what now I want is to add a button where, when clicked the user is directed to the inbuilt application details screen with the force stop and uninstall option, since I only take user installed application I don't need root permission and as well as system permission. is there a way to call that system intent inside my application.
try as:
Intent detailsIntent = new Intent();
detailsIntent.setClassName("com.android.settings",
"com.android.settings.InstalledAppDetails");
//ApiLevel greater than or equal to 8
detailsIntent.putExtra("pkg", "Appliction_Package_NAme");
//ApiLevel in less than 8
detailsIntent.putExtra("com.android.settings.ApplicationPkgName",
"Appliction_Package_NAme");
startActivity(detailsIntent);
try this
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:app package name"));
startActivity(intent);