List of usage examples for android.provider Settings ACTION_NFC_SETTINGS
String ACTION_NFC_SETTINGS
To view the source code for android.provider Settings ACTION_NFC_SETTINGS.
Click Source Link
From source file:com.mario22gmail.license.nfc_project.FragmentEnableNFC.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment final View view = inflater.inflate(R.layout.fragment_enable_nfc, container, false); getDialog().requestWindowFeature(STYLE_NO_TITLE); Button buttonGoSettings = (Button) view.findViewById(R.id.buttonEnableNfcGoSettingButton); buttonGoSettings.setOnClickListener(new View.OnClickListener() { @Override//from w ww . j ava2 s . c om public void onClick(View v) { startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } }); return view; }
From source file:de.persoapp.android.activity.dialog.NfcDeactivatedDialog.java
@SuppressWarnings("ConstantConditions") @Override/* ww w. j av a2 s .co m*/ public void onResume() { super.onResume(); if (mNfcManager.getDefaultAdapter().isEnabled()) { dismiss(); mEventBus.post(new InitializeAppFragment.OnAppInitialized(true)); } 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_NFC_SETTINGS)); } }); } }
From source file:edu.cmu.cylab.starslinger.demo.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_MSG: showMessage(getString(R.string.dev_app_name_long), getString(R.string.dev_instruct)); return true; case MENU_NFC: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } else {//from ww w . jav a2 s . c om startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } break; default: break; } return false; }
From source file:com.phonegap.plugins.nativesettings.NativeSettings.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; Uri packageUri = Uri.parse("package:" + this.cordova.getActivity().getPackageName()); String result = ""; //Information on settings can be found here: //http://developer.android.com/reference/android/provider/Settings.html action = args.getString(0);//from w w w.j av a 2s. com Intent intent = null; if (action.equals("accessibility")) { intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); } else if (action.equals("account")) { intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); } else if (action.equals("airplane_mode")) { intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS); } else if (action.equals("apn")) { intent = new Intent(android.provider.Settings.ACTION_APN_SETTINGS); } else if (action.equals("application_details")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri); } else if (action.equals("application_development")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); } else if (action.equals("application")) { intent = new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS); } //else if (action.equals("battery_saver")) { // intent = new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS); //} else if (action.equals("bluetooth")) { intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); } else if (action.equals("captioning")) { intent = new Intent(android.provider.Settings.ACTION_CAPTIONING_SETTINGS); } else if (action.equals("cast")) { intent = new Intent(android.provider.Settings.ACTION_CAST_SETTINGS); } else if (action.equals("data_roaming")) { intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); } else if (action.equals("date")) { intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS); } else if (action.equals("about")) { intent = new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS); } else if (action.equals("display")) { intent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS); } else if (action.equals("dream")) { intent = new Intent(android.provider.Settings.ACTION_DREAM_SETTINGS); } else if (action.equals("home")) { intent = new Intent(android.provider.Settings.ACTION_HOME_SETTINGS); } else if (action.equals("keyboard")) { intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS); } else if (action.equals("keyboard_subtype")) { intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); } else if (action.equals("storage")) { intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS); } else if (action.equals("locale")) { intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS); } else if (action.equals("location")) { intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); } else if (action.equals("manage_all_applications")) { intent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS); } else if (action.equals("manage_applications")) { intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); } else if (action.equals("memory_card")) { intent = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS); } else if (action.equals("network")) { intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS); } else if (action.equals("nfcsharing")) { intent = new Intent(android.provider.Settings.ACTION_NFCSHARING_SETTINGS); } else if (action.equals("nfc_payment")) { intent = new Intent(android.provider.Settings.ACTION_NFC_PAYMENT_SETTINGS); } else if (action.equals("nfc_settings")) { intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS); } //else if (action.equals("notification_listner")) { // intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS); //} else if (action.equals("print")) { intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS); } else if (action.equals("privacy")) { intent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS); } else if (action.equals("quick_launch")) { intent = new Intent(android.provider.Settings.ACTION_QUICK_LAUNCH_SETTINGS); } else if (action.equals("search")) { intent = new Intent(android.provider.Settings.ACTION_SEARCH_SETTINGS); } else if (action.equals("security")) { intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS); } else if (action.equals("settings")) { intent = new Intent(android.provider.Settings.ACTION_SETTINGS); } else if (action.equals("show_regulatory_info")) { intent = new Intent(android.provider.Settings.ACTION_SHOW_REGULATORY_INFO); } else if (action.equals("sound")) { intent = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS); } else if (action.equals("store")) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + this.cordova.getActivity().getPackageName())); } else if (action.equals("sync")) { intent = new Intent(android.provider.Settings.ACTION_SYNC_SETTINGS); } else if (action.equals("usage")) { intent = new Intent(android.provider.Settings.ACTION_USAGE_ACCESS_SETTINGS); } else if (action.equals("user_dictionary")) { intent = new Intent(android.provider.Settings.ACTION_USER_DICTIONARY_SETTINGS); } else if (action.equals("voice_input")) { intent = new Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS); } else if (action.equals("wifi_ip")) { intent = new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS); } else if (action.equals("wifi")) { intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS); } else if (action.equals("wireless")) { intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); } else { status = PluginResult.Status.INVALID_ACTION; callbackContext.sendPluginResult(new PluginResult(status, result)); return false; } if (args.length() > 1 && args.getBoolean(1)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } this.cordova.getActivity().startActivity(intent); callbackContext.sendPluginResult(new PluginResult(status, result)); return true; }
From source file:org.esupportail.nfctagdroid.NfcTacDroidActivity.java
public boolean checkHardware(NfcAdapter mAdapter) { if (mAdapter == null) { Toast.makeText(this, getString(R.string.msg_error_nfc), Toast.LENGTH_LONG).show(); finish();// w w w .j ava 2s. co m return false; } if (!mAdapter.isEnabled()) { Toast.makeText(this, getString(R.string.msg_activ_nfc), Toast.LENGTH_LONG).show(); startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } if (!isOnline()) { view.loadUrl("about:blank"); Toast.makeText(this, getString(R.string.msg_activ_network), Toast.LENGTH_LONG).show(); startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); } return true; }
From source file:org.sufficientlysecure.keychain.ui.PassphraseWizardActivity.java
public void showAlertDialog(String message, boolean nfc) { //This method shows an AlertDialog AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Information").setMessage(message).setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a2 s .co m*/ public void onClick(DialogInterface dialogInterface, int i) { } }); if (nfc) { alert.setNeutralButton(R.string.nfc_settings, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } }); } alert.show(); }
From source file:com.support.android.designlibdemo.EditContactActivity.java
/** * Create a dialog that send user to NFC settings if NFC is off (and save * the dialog in {@link #mEnableNfc}). Alternatively the user can choos to * use the App in editor only mode or exit the App. *//*from w w w . j a v a 2 s. com*/ private void createNfcEnableDialog() { mEnableNfc = new AlertDialog.Builder(this).setTitle(R.string.dialog_nfc_not_enabled_title) .setMessage(R.string.dialog_nfc_not_enabled).setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(R.string.action_nfc, new DialogInterface.OnClickListener() { @Override @SuppressLint("InlinedApi") public void onClick(DialogInterface dialog, int which) { // Goto NFC Settings. if (Build.VERSION.SDK_INT >= 16) { startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } else { startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } } }).setNeutralButton(R.string.action_editor_only, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Only use Editor. } }).setNegativeButton(R.string.action_exit_app, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Exit the App. finish(); } }).create(); }
From source file:de.syss.MifareClassicTool.Activities.MainMenu.java
/** * Create a dialog that send user to NFC settings if NFC is off (and save * the dialog in {@link #mEnableNfc}). Alternatively the user can choos to * use the App in editor only mode or exit the App. *//*from www .j ava2 s. c o m*/ private void createNfcEnableDialog() { mEnableNfc = new AlertDialog.Builder(this).setTitle(R.string.dialog_nfc_not_enabled_title) .setMessage(R.string.dialog_nfc_not_enabled).setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(R.string.action_nfc, new DialogInterface.OnClickListener() { @Override @SuppressLint("InlinedApi") public void onClick(DialogInterface dialog, int which) { // Goto NFC Settings. if (Build.VERSION.SDK_INT >= 16) { startActivity(new Intent(Settings.ACTION_NFC_SETTINGS)); } else { startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } } }).setNeutralButton(R.string.action_editor_only, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Only use Editor. Common.setUseAsEditorOnly(true); } }).setNegativeButton(R.string.action_exit_app, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Exit the App. finish(); } }).create(); }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override public void onClick(View v) { // If OK(setPin) clicked, ask user if sure; if yes, store PIN; else, go back if (v.getId() == R.id.setPin) { // If PIN length between 4 and 6, store PIN and toast successful if (pinEdit.length() >= 4 && pinEdit.length() <= 6) { new AlertDialog.Builder(this).setMessage(R.string.set_pin_confirmation) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { settings.put("pin", String.valueOf(pinEdit.getText())); } catch (JSONException e) { e.printStackTrace(); }//www . ja v a 2 s.com writeToJSON(); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_pin_set, Toast.LENGTH_SHORT); toast.show(); imm.hideSoftInputFromWindow(pinEdit.getWindowToken(), 0); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { imm.hideSoftInputFromWindow(pinEdit.getWindowToken(), 0); // Do nothing, close dialog } }).show(); } // Toast user that PIN needs to be at least 4 digits long else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_pin_needs4digits, Toast.LENGTH_LONG); toast.show(); } } // If 'Refresh wallpaper' pressed, check if Android 4.2 or above, if yes // Store new blur var, if blur bigger than 0 re-blur wallpaper else if (v.getId() == R.id.refreshWallpaper) { if (Build.VERSION.SDK_INT > 16) { try { settings.put("blur", blur); } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); // If blur is 0, don't change anything, just toast if (blur == 0) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_refreshed, Toast.LENGTH_SHORT); toast.show(); } // If blur is bigger than 0, get default wallpaper - to bitmap - fastblur bitmap - store else { // Check if TapUnlock folder exists, if not, create directory File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock"); boolean folderSuccess = true; if (!folder.exists()) { folderSuccess = folder.mkdir(); } if (folderSuccess) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Display indeterminate progress bar while blurring progressBar.setVisibility(View.VISIBLE); new Thread(new Runnable() { @Override public void run() { Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable); Bitmap blurredWallpaper = null; if (bitmapToBlur != null) blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur, blur); boolean stored = false; if (blurredWallpaper != null) { stored = ImageUtils.storeImage(blurredWallpaper); final boolean finalStored = stored; runOnUiThread(new Runnable() { @Override public void run() { progressBar.setVisibility(View.INVISIBLE); if (finalStored) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_refreshed, Toast.LENGTH_SHORT); toast.show(); } } }); } if (bitmapToBlur == null || blurredWallpaper == null || !stored) { runOnUiThread(new Runnable() { @Override public void run() { progressBar.setVisibility(View.INVISIBLE); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_not_refreshed, Toast.LENGTH_SHORT); toast.show(); } }); } } }).start(); } else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_not_refreshed, Toast.LENGTH_SHORT); toast.show(); } } } } // If Android version less than 4.2, display toast cannot blur else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_cannot_blur, Toast.LENGTH_SHORT); toast.show(); } } // If '+' pressed else if (v.getId() == R.id.newTag) { if (nfcAdapter != null) { // If NFC is on, show scan dialog and enableForegroundDispatch if (nfcAdapter.isEnabled()) { nfcAdapter.enableForegroundDispatch(this, pIntent, new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) }, new String[][] { new String[] { "android.nfc.tech.MifareClassic" }, new String[] { "android.nfc.tech.MifareUltralight" }, new String[] { "android.nfc.tech.NfcA" }, new String[] { "android.nfc.tech.NfcB" }, new String[] { "android.nfc.tech.NfcF" }, new String[] { "android.nfc.tech.NfcV" }, new String[] { "android.nfc.tech.Ndef" }, new String[] { "android.nfc.tech.IsoDep" }, new String[] { "android.nfc.tech.NdefFormatable" } }); MainActivity.this.showDialog(DIALOG_READ); } // NFC is off, prompt user to enable it and send him to NFC settings else { new AlertDialog.Builder(this).setTitle(R.string.nfc_off_dialog_title) .setMessage(R.string.nfc_off_dialog_message) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS); startActivity(intent); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing, close dialog } }).show(); } } // NFC adapter is null else { new AlertDialog.Builder(this).setTitle(R.string.nfc_off_dialog_title) .setMessage(R.string.nfc_off_dialog_message) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS); startActivity(intent); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing, close dialog } }).show(); } } }
From source file:com.moonpi.tapunlock.MainActivity.java
public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { if (isChecked) { // If NFC is on if (nfcAdapter.isEnabled()) { try { // If no PIN remembered, toast user to enter a PIN if (settings.getString("pin").equals("")) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_lock_set_pin, Toast.LENGTH_LONG); toast.show();//from w w w . j a v a2 s . c o m buttonView.setChecked(false); } // If no NFC Tag remembered, toast user to scan an NFC Tag else if (tags.length() == 0) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_lock_add_tag, Toast.LENGTH_LONG); toast.show(); // Set lockscreen false, stop service and store try { if (settings.getBoolean("lockscreen")) { settings.put("lockscreen", false); enabled_disabled.setText(R.string.lockscreen_disabled); enabled_disabled.setTextColor(getResources().getColor(R.color.red)); } } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); killService(this); buttonView.setChecked(false); } // If everything ok, set lockscreen true, start service and store else { if (!onStart) { try { settings.put("lockscreen", true); enabled_disabled.setText(R.string.lockscreen_enabled); enabled_disabled.setTextColor(getResources().getColor(R.color.green)); startService(new Intent(this, ScreenLockService.class)); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_lock_enabled, Toast.LENGTH_SHORT); toast.show(); } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); return; } onStart = false; startService(new Intent(this, ScreenLockService.class)); } } catch (JSONException e) { e.printStackTrace(); } } // NFC is off, prompt user to enable it and send him to NFC settings else { new AlertDialog.Builder(this).setTitle(R.string.nfc_off_dialog_title) .setMessage(R.string.nfc_off_dialog_message) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS); startActivity(intent); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Do nothing, close dialog } }).show(); // Set lockscreen false, stop service and store try { if (settings.getBoolean("lockscreen")) settings.put("lockscreen", false); } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); enabled_disabled.setText(R.string.lockscreen_disabled); enabled_disabled.setTextColor(getResources().getColor(R.color.red)); killService(this); buttonView.setChecked(false); } } // If unchecked, set lockscreen false, stop service and store else { try { settings.put("lockscreen", false); } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); enabled_disabled.setText(R.string.lockscreen_disabled); enabled_disabled.setTextColor(getResources().getColor(R.color.red)); killService(this); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_lock_disabled, Toast.LENGTH_SHORT); toast.show(); } }