Skip to content Skip to sidebar Skip to footer

Alarm Dialog For Turn On Wifi

I am new in android programming. I searched on the internet but i can't find any solution, maybe for this i have not good english. anyway. When user clicked on the web link i want

Solution 1:

Try this on button click:

AlertDialog.BuilderalertDialog=newAlertDialog.Builder(
                this);

        // Setting Dialog Title
        alertDialog.setTitle("Confirm...");

        // Setting Dialog Message
        alertDialog.setMessage("Do you want to go to wifi settings?");

        // Setting Icon to Dialog// alertDialog.setIcon(R.drawable.ic_launcher);// Setting Positive "Yes" Button
        alertDialog.setPositiveButton("yes",
                newDialogInterface.OnClickListener() {
                    publicvoidonClick(DialogInterface dialog, int which) {

                        // Activity transfer to wifi settings
                        startActivity(newIntent(Settings.ACTION_WIFI_SETTINGS));
                    }
                });

        // Setting Negative "NO" Button
        alertDialog.setNegativeButton("no",
                newDialogInterface.OnClickListener() {
                    publicvoidonClick(DialogInterface dialog, int which) {
                        // Write your code here to invoke NO event

                        dialog.cancel();
                    }
                });

        // Showing Alert Message
        alertDialog.show();

Solution 2:

This should work

startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));

Solution 3:

Try adding the following to the onClick of Button

context.startActivity(newIntent(WifiManager.ACTION_PICK_WIFI_NETWORK));

This will redirect the user directly to the wifi settings screen

Hope this works

Post a Comment for "Alarm Dialog For Turn On Wifi"