Example usage for android.provider Settings ACTION_WIFI_SETTINGS

List of usage examples for android.provider Settings ACTION_WIFI_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_WIFI_SETTINGS.

Prototype

String ACTION_WIFI_SETTINGS

To view the source code for android.provider Settings ACTION_WIFI_SETTINGS.

Click Source Link

Document

Activity Action: Show settings to allow configuration of Wi-Fi.

Usage

From source file:Main.java

public static void openWifi(Activity context) {
    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
}

From source file:Main.java

public static void openSetting(Activity activity) {
    Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
    activity.startActivity(intent);
}

From source file:Main.java

public static void toWIFISettingActivity(Context mContext) {
    Intent wifiSettingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
    mContext.startActivity(wifiSettingsIntent);
}

From source file:Main.java

/**
 * wifi settings/*from   ww  w  .  ja v a 2s . com*/
 * 
 * @param context
 */
public static void wifiSettings(Context context) {
    if (context == null)
        return;

    try {
        context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
    } catch (ActivityNotFoundException e) {
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void showWifiSettings(final Activity activity, final Runnable yes, final Runnable no) {
    // check for internet connection
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
    alertDialog.setTitle("No Internet Connection");
    alertDialog.setMessage("Would you like to change settings ?");
    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            if (yes != null)
                yes.run();//from   w  w w  .jav  a  2s  .c om
        }
    });
    // Setting Negative "NO" Button
    alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            if (no != null)
                no.run();
        }
    });
    // Showing Alert Message
    alertDialog.show();
}

From source file:com.whitebyte.hotspotcontrolexample.Main.java

public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
    case 0://  w w  w .  jav a  2 s  . c  om
        scan();
        break;
    case 1:
        wifiApManager.setWifiApEnabled(null, true);
        break;
    case 2:
        wifiApManager.setWifiApEnabled(null, false);
        break;
    case 3:
        startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
        break;
    }

    return super.onMenuItemSelected(featureId, item);
}

From source file:de.persoapp.android.activity.dialog.NoInternetConnectionDialog.java

@SuppressWarnings("ConstantConditions")
@Override//from ww  w.j  a va2 s.  c o  m
public void onResume() {
    super.onResume();

    if (mNetworkHelper.isNetworkAvailable()) {
        closeDialog();

    } else {
        AlertDialog dialog = (AlertDialog) getDialog();

        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            }
        });

        getActivity().registerReceiver(mBroadcastReceiver,
                new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
        mRegistered = true;
    }
}

From source file:org.projectbuendia.client.ui.BaseActivity.java

/** Called when the set of troubleshooting actions changes. */
public void onEventMainThread(TroubleshootingActionsChangedEvent event) {
    if (event.actions.isEmpty()) {
        setStatusView(null);/*from   w  w w.j  ava2  s.  c o m*/
        setStatusVisibility(View.GONE);

        return;
    }

    TroubleshootingAction troubleshootingAction = event.actions.iterator().next();

    View view = getLayoutInflater().inflate(R.layout.view_status_bar_default, null);
    final TextView message = (TextView) view.findViewById(R.id.status_bar_default_message);
    final TextView action = (TextView) view.findViewById(R.id.status_bar_default_action);

    switch (troubleshootingAction) {
    case ENABLE_WIFI:
        message.setText(R.string.troubleshoot_wifi_disabled);
        action.setText(R.string.troubleshoot_wifi_disabled_action_enable);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                action.setEnabled(false);

                ((WifiManager) getSystemService(Context.WIFI_SERVICE)).setWifiEnabled(true);
            }
        });
        break;
    case CONNECT_WIFI:
        message.setText(R.string.troubleshoot_wifi_disconnected);
        action.setText(R.string.troubleshoot_wifi_disconnected_action_connect);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                action.setEnabled(false);

                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            }
        });
        break;
    case CHECK_SERVER_AUTH:
        message.setText(R.string.troubleshoot_server_auth);
        action.setText(R.string.troubleshoot_server_auth_action_check);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                action.setEnabled(false);

                startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
            }
        });
        break;
    case CHECK_SERVER_CONFIGURATION:
        message.setText(R.string.troubleshoot_server_address);
        action.setText(R.string.troubleshoot_server_address_action_check);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                action.setEnabled(false);

                startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
            }
        });
        break;
    case CHECK_SERVER_REACHABILITY:
        message.setText(R.string.troubleshoot_server_unreachable);
        action.setText(R.string.troubleshoot_action_more_info);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // TODO: Display the actual server URL that couldn't be reached in
                // this message. This will require that injection be hooked up through to
                // this inner class, which may be complicated.
                showMoreInfoDialog(action, getString(R.string.troubleshoot_server_unreachable),
                        getString(R.string.troubleshoot_server_unreachable_details), true);
            }
        });
        break;
    case CHECK_SERVER_SETUP:
        message.setText(R.string.troubleshoot_server_unstable);
        action.setText(R.string.troubleshoot_action_more_info);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // TODO: Display the actual server URL that couldn't be reached in
                // this message. This will require that injection be hooked up through to
                // this inner class, which may be complicated.
                showMoreInfoDialog(action, getString(R.string.troubleshoot_server_unstable),
                        getString(R.string.troubleshoot_server_unstable_details), false);
            }
        });
        break;
    case CHECK_SERVER_STATUS:
        message.setText(R.string.troubleshoot_server_not_responding);
        action.setText(R.string.troubleshoot_action_more_info);
        action.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // TODO: Display the actual server URL that couldn't be reached in
                // this message. This will require that injection be hooked up through to
                // this inner class, which may be complicated.
                showMoreInfoDialog(action, getString(R.string.troubleshoot_server_not_responding),
                        getString(R.string.troubleshoot_server_not_responding_details), false);
            }
        });
        break;
    case CHECK_UPDATE_SERVER_REACHABILITY:
        message.setText(R.string.troubleshoot_update_server_unreachable);
        action.setText(R.string.troubleshoot_action_more_info);
        action.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showMoreInfoDialog(action, getString(R.string.troubleshoot_update_server_unreachable),
                        getString(R.string.troubleshoot_update_server_unreachable_details), true);
            }
        });
        break;
    case CHECK_UPDATE_SERVER_CONFIGURATION:
        message.setText(R.string.troubleshoot_update_server_misconfigured);
        action.setText(R.string.troubleshoot_action_more_info);
        action.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showMoreInfoDialog(action, getString(R.string.troubleshoot_update_server_misconfigured),
                        getString(R.string.troubleshoot_update_server_misconfigured_details), true);
            }
        });
        break;
    default:
        LOG.w("Troubleshooting action '%1$s' is unknown.", troubleshootingAction);
        return;
    }

    setStatusView(view);
    setStatusVisibility(View.VISIBLE);
}

From source file:org.kde.necessitas.ministro.MinistroActivity.java

private void checkNetworkAndDownload(final boolean update) {
    if (isOnline(this))
        new CheckLibraries().execute(update);
    else {//from w  w  w . java  2s  .  c om
        AlertDialog.Builder builder = new AlertDialog.Builder(MinistroActivity.this);
        builder.setMessage(getResources().getString(R.string.ministro_network_access_msg));
        builder.setCancelable(true);
        builder.setNeutralButton(getResources().getString(R.string.settings_msg),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        final ProgressDialog m_dialog = ProgressDialog.show(MinistroActivity.this, null,
                                getResources().getString(R.string.wait_for_network_connection_msg), true, true,
                                new DialogInterface.OnCancelListener() {
                                    public void onCancel(DialogInterface dialog) {
                                        finishMe();
                                    }
                                });
                        getApplication().registerReceiver(new BroadcastReceiver() {
                            @Override
                            public void onReceive(Context context, Intent intent) {
                                if (isOnline(MinistroActivity.this)) {
                                    try {
                                        getApplication().unregisterReceiver(this);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            m_dialog.dismiss();
                                            new CheckLibraries().execute(update);
                                        }
                                    });
                                }
                            }
                        }, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
                        try {
                            startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
                        } catch (Exception e) {
                            e.printStackTrace();
                            try {
                                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                            } catch (Exception e1) {

                                e1.printStackTrace();
                            }
                        }
                        dialog.dismiss();
                    }
                });
        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                finishMe();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:com.otaupdater.OTAUpdaterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);/*www  .  j  av  a  2s. c om*/

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}