Getting the Bluetooth settings Connect & pair screen using intent? - android

I want to navigate directly to the bluetooth settings Connect & pair screen on a button click now I can navigate till the wireless settings..
My code is as follows:
Intent i=new Intent();
i.setClassName("com.android.settings","com.android.settings.WirelessSettings");
startActivity(i);

It's pretty simple, try this:
Intent settingsIntent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(settingsIntent);

Use the follwoing:
Intent settings_intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
startActivityForResult(settings_intent, 0);
This way you will open Bluetooth settings page and later return back to your activity that started the Intent.

Related

Open specific Settings-page programmatically

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).

Android - launching intent for Restrict Background Data

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);

Show only wireless system settings on Android 3

This code works perfectly:
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
But Android 3 show also another preferences. How do I can show to user only wireless settings?
UPD This code:
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.phone", "com.android.phone.Settings");
startActivity(intent);
starts a mobile settings. Is there something like that for wi-fi (turn in\off, setting ip-address etc)?
You can show only the wireless settings fragment by adding the following extras to your intent
Intent i = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
i.putExtra(":android:show_fragment", "com.android.settings.wifi.WifiSettings");
i.putExtra(":android:no_headers", true);
startActivity(i);
But Android 3 show also another preferences.
The activity you are starting is part of the Settings application, which you did not write. The Settings application can display whatever it wants. In the case of tablets, the Settings application will generally show all preferences, with the one tied to your Intent action be the currently-selected one.
How do I can show to user only wireless settings?
Write your own firmware with your own implementation of the Settings app that does what you want, and install that firmware on the user's device.
You can access only Wifi settings by using this
Intent i = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK);
startActivity(i);
Extra options(for back and next buttons)
Intent i = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK);
i.putExtra("extra_prefs_show_button_bar", true);
startActivity(i);

Android - Launching Main Settings Activity not always working

FLAG_ACTIVITY_NO_HISTORY is not working for starting android settings activity (android.provider.Settings.ACTION_SETTINGS)
I have an activity from which I start Android Settings Window (android.provider.Settings.ACTION_SETTINGS). I do it like that:
Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
activityContext.startActivity(intent);
It usually works. However, when I follow these steps:
1) launch settings from my activity
2) go further (i.e. Wireless & networks),
3) press home, etc
3) launch my activity again
4) launch settings from my activity
5) then 'Wireless & networks' screen appears instead of main android settings activity!
I also tried:
Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activityContext.startActivity(intent);
But it's not working either. Do you know what might be the problem? I wanted to add that flag FLAG_ACTIVITY_NO_HISTORY works for my internal activities.
Try adding the flag Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED to the intent.

Accessing Android Inbox/Messaging from Activity?

Is it possible to open up the default Android Messaging activity from inside an activity you write yourself? Like for example: I press a "Mail" button inside my program, and it opens the Android Messaging app just like as if I was to press the Messaging icon on the main screen.
I did something similar to this with the Contacts activity, but only the contact list comes up, no extra functionality like Adding/Modifying/Deleting, etc.
Any ideas?
edit: I found this way to open the "Compose New Message" Activity, I just need to back it up a step. Does anyone know the correct MIME type instead of this one?
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
m_activity.startActivity(sendIntent);
This starts the messaging app from another app:
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(new ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
startActivity(intent);
Just put it inside a button listener or whatever user input you want to open it from.
Enjoy :-)
If you want to open the messaging app to view messages and not for sending a message, this should do the job:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage("com.google.android.apps.messaging");
startActivity(intent);

Categories

Resources