Back to project page permission-explorer.
The source code is released under:
Copyright (C) 2012 Rui Gon?alves and Daniel Cibr?o Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),...
If you think the Android project permission-explorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pt.up.fe.ssin.pexplorer.actions; // w w w . j a v a 2 s .co m import pt.up.fe.ssin.pexplorer.R; import pt.up.fe.ssin.pexplorer.app.PermissionAction; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.net.wifi.WifiManager; public class ChangeWifiStateAction extends PermissionAction { public ChangeWifiStateAction() { super(R.string.wifi_state_label, R.string.write_calendar_label, PermissionAction.DO_NOTHING); } @Override protected void doAction(final Context context) { WifiManager wifi = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); String message = new String(); if (wifi.isWifiEnabled()) { wifi.setWifiEnabled(false); message = context.getString(R.string.wifi_state_shutdown); } else { wifi.setWifiEnabled(true); message = context.getString(R.string.wifi_state_activated); } new AlertDialog.Builder(context) .setTitle(R.string.wifi_state_label) .setMessage(message) .setCancelable(true) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }).show(); } }