Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I overlay a 'back' and 'next' button on a " pick wifi network " window?

Tags:

android

Google play does this when you try to use it and happen to not be connected to a wifi network.

photo of what I'm trying to do:

image

If you just run a standard

startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));

Then it loads up the window I'm looking for. However, I want a 'back' and 'next' button overlayed on top of it. Back should return to the previous window and next should only be selectable if a network has been selected and authentication is performed (if required). It would then go to another activity.

I tried implementing it with fragments (one for the intent launched window and another for the button), but it isn't working.

This was the code that launched when the app did

public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layfile);
//        Intent n = new Intent(this,Pactivity.class);
//        startActivity(n);
//        
    }
}

public class Pactivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    //addPreferencesFromIntent(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
    setContentView(R.layout.main);

}

}

public class Pfrag extends PreferenceFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.preferences);
    }
}

Here are the xml files

<?xml version="1.0" encoding="UTF-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >    
    <Preference 
        android:key="key"   
        android:title="WiFi" 
        android:summary="Calls WiFi">           
            <intent android:action="android.net.wifi.PICK_WIFI_NETWORK"/>           
    </Preference>
</PreferenceScreen>

I also tried some thrown together Preferences based classes. Also not doing what I want.

How can I get buttons overlayed on to what you see with a WifiManager.ACTION_PICK_WIFI_NETWORK?

like image 328
Sojurn Avatar asked Jun 26 '12 19:06

Sojurn


1 Answers

    Intent intent = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK);       
    intent.putExtra("only_access_points", true);
    intent.putExtra("extra_prefs_show_button_bar", true);
    intent.putExtra("wifi_enable_next_on_connect", true);
    startActivityForResult(intent, 1);

This should do it. Reverse engineered from google code.

like image 71
UncleKing Avatar answered Oct 16 '22 12:10

UncleKing