开发者

Send user to preferences on Android after button is clicked

I have an Android app which requires the user to be connected to the Internet. If the user is not online, the app shows an AlertDialog which says: "You have to be connected to the Internet to use this app". In that AlertDialog I have a button. Can I some how send the user to preferences, so the user can turn internet on and return to 开发者_如何学编程my app? So when the user returns I just run my methods to get the information from the services I use.


Use this code:

    startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));

EDIT: you could use:

    startActivityForResult(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), PICK_WIFI_REQUEST_CODE);

and then override:

   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       //Check if you have internet
       //... proceed to next Activity
   }


Create a new Intent using the current class activity and the WifiManager constant to search for network/pick a network. Start the activity and wait for result.

Intent intent = new Intent(activity.this, WifiManager.ACTION_PICK_WIFI_NETWORK);
startActivityForResult(intent,1)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜