ukim
ukim

Reputation: 2477

Android: how to start setting activity with back button

When I start Wifi setting page from android's setting page, there is a back button in the top action bar. But there is not when I start Wifi setting from my own app.

The code I am using is:

Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
startActivity(intent);

I know that the wifi setting activity and my activity are already in the same back stack. Is there any way to show the back button in the action bar?

Upvotes: 2

Views: 1019

Answers (2)

Tim OMalley
Tim OMalley

Reputation: 423

Try adding

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

or try

Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
    intent.setComponent(cn);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity( intent);

Upvotes: 1

Ben P.
Ben P.

Reputation: 54214

As far as I'm aware, there's no way to do what you want. However, I think that even if there were, it is unlikely that you would actually want to do it.

The "back" button in the action bar is actually an Up button. Clicking it wouldn't take the user back to your app; it would take the user up one level within the device settings.

https://developer.android.com/design/patterns/navigation.html

Upvotes: 1

Related Questions