我如何可以覆盖一个'回'和A&QUOT“下一步”按钮;挑wifi网络"窗口?下一步、按钮、窗口、网络

2023-09-07 11:28:35 作者:一又二分之一的夏天

谷歌播放做到这一点,当您尝试使用它而发生不被连接到WiFi网络。

照片是我想要做的:

如果你只是运行一个标准

  startActivity(新意图(WifiManager.ACTION_PICK_WIFI_NETWORK));
 

然后,它加载了我要找的窗口。不过,我希望有一个返回和下一步按钮,覆盖在它上面。回应该返回到previous窗口和下一如果网络已经选择并执行身份验证(如果需要的话)应该只可选择的。然后,它将转到另一个活动。

我试着用片段(一个用于意图推出窗口,另一个按钮)实现它,但它不能正常工作。

从败家子到摇钱树 复盘云计算三巨头崛起之路

这是code,它推出时,应用程序的确

 公共类TestActivity延伸活动{
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.layfile);
//意图N =新的意图(这一点,Pactivity.class);
// startActivity(N);
//
    }
}

公共类Pactivity扩展preferenceActivity {
@覆盖
保护无效的onCreate(包savedInstanceState){
    // TODO自动生成方法存根
    super.onCreate(savedInstanceState);
    加preferencesFromResource(R.xml preferences。);
    //添加preferencesFromIntent(新意图(WifiManager.ACTION_PICK_WIFI_NETWORK));
    的setContentView(R.layout.main);

}

}

公共类Pfrag扩展preferenceFragment {

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        //从XML资源负载的preferences
        加preferencesFromResource(R.xml preferences。);
    }
}
 

下面是XML文件

 < XML版本=1.0编码=UTF-8&GT?;

< preferenceScreen的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    < preference
        机器人:键=钥匙
        机器人:标题=无线网络连接
        机器人:总结=召唤无线>
            <意图安卓行动=android.net.wifi.PICK_WIFI_NETWORK/>
    < / preference>
< / preferenceScreen>
 

我也尝试了一些拼凑起来的基础课preferences。也没有做什么,我想要的。

我怎样才能覆盖在什么你看到按钮的 WifiManager.ACTION_PICK_WIFI_NETWORK

解决方案

 意向意图=新的意图(WifiManager.ACTION_PICK_WIFI_NETWORK);
    intent.putExtra(only_access_points,真正的);
    intent.putExtra(EXTRA_ prefs_show_button_bar,真正的);
    intent.putExtra(wifi_enable_next_on_connect,真正的);
    startActivityForResult(意向,1);
 

这应该这样做。 反向从谷歌code设计的。

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:

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?

解决方案

    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.