Show only wireless system settings on Android 3 - android

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

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

Directly list the available networks in android phone programmatically

I need to directly display the list of available networks in android phone instead of following the options Wireless&networks->Mobilenetworks->Network operators->Select manually etc, is it possible to directly display the list of available networks without following the above steps i tried the following codes..
startActivityForResult(new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS), 0);
The second thing i tried is
Intent intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
startActivity(intent);
The third one which i tried is
Intent intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
startActivity(intent);
When i tried the third one i got the select manually and choose automatically screen but it is blinking and goes off.
What are all the other options which i can use to select the network without any options?

Android Start VPNClient (com.ipsec.vpnclient) Programmatically

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

How to display only specific Settings fragment from android inbuilt Settings app

I want to show only wi-fi settings fragment from settings. I have achieved this by using following code:
Intent i = new Intent(Settings.ACTION_SETTINGS);
i.putExtra(":android:show_fragment", "com.android.settings.wifi.WifiSettings");
i.putExtra(":android:no_headers", true);
startActivity(i);
Now I want to show only date & time fragment from settings so I changed my code to:
Intent i = new Intent(Settings.ACTION_SETTINGS);
i.putExtra(":android:show_fragment","com.android.settings.ACTION_DATE_SETTINGS");
i.putExtra(":android:no_headers", true);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
unfortunately it's not working.How can I display only specific Settings fragment from android inbuilt Settings app like this
I want to show only wi-fi settings fragment from settings. I have achieved this by using following code:
I would recommend that you use ACTION_WIFI_SETTINGS and get rid of the undocumented extras.
Now I want to show only date & time fragment from settings so I changed my code... unfortunately it's not working.
The right solution is to use ACTION_DATE_SETTINGS and get rid of the undocumented extras. Beyond that, com.android.settings.ACTION_DATE_SETTINGS is not the name of a fragment.
Evidently no_headers was silently removed from Android L and above... so we are out of luck. Re-write just select pieces of com.android.settings and block the standard settings through MDM - then pray for SYSTEM signature on your app.

Getting the Bluetooth settings Connect & pair screen using intent?

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.

Categories

Resources