List of usage examples for android.content Context NFC_SERVICE
String NFC_SERVICE
To view the source code for android.content Context NFC_SERVICE.
Click Source Link
From source file:de.schildbach.litecoinwallet.ui.RequestCoinsFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractBindServiceActivity) activity; this.application = (WalletApplication) activity.getApplication(); this.wallet = application.getWallet(); this.prefs = PreferenceManager.getDefaultSharedPreferences(activity); this.loaderManager = getLoaderManager(); this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE); this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); }
From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.FixturesFragment.java
/** * Updates the NFC Status/*from ww w .j a v a 2 s. co m*/ */ @TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1) private void updateNFCStatusDisplay() { final NfcManager nfcManager = (NfcManager) getActivity().getSystemService(Context.NFC_SERVICE); final NfcAdapter adapter = nfcManager.getDefaultAdapter(); nfc.setText(Boolean.toString(adapter != null && adapter.isEnabled())); }
From source file:cc.mintcoin.wallet.ui.RequestCoinsFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractBindServiceActivity) activity; this.application = (WalletApplication) activity.getApplication(); this.config = application.getConfiguration(); this.wallet = application.getWallet(); this.loaderManager = getLoaderManager(); this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE); this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { actionBarTitleView.setTypeface(lobsterTwo); actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f); actionBarTitleView.setTextColor(getResources().getColor(R.color.blue)); }/* w w w . j a v a 2 s .c o m*/ setContentView(R.layout.activity_main); // Hide keyboard on app launch this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Get NFC service and adapter NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE); nfcAdapter = nfcManager.getDefaultAdapter(); // Create PendingIntent for enableForegroundDispatch for NFC tag discovery pIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); readFromJSON(); writeToJSON(); readFromJSON(); // If Android 4.2 or bigger if (Build.VERSION.SDK_INT > 16) { // 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(); } try { // If blur var bigger than 0 if (settings.getInt("blur") > 0) { // If folder exists or successfully created if (folderSuccess) { // If blurred wallpaper file doesn't exist if (!ImageUtils.doesBlurredWallpaperExist()) { // Get default wallpaper WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap 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); if (blurredWallpaper != null) { ImageUtils.storeImage(blurredWallpaper); } } }).start(); } } } } } catch (JSONException e) { e.printStackTrace(); } } // Initialize layout items pinEdit = (EditText) findViewById(R.id.pinEdit); pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE); Button setPin = (Button) findViewById(R.id.setPin); ImageButton newTag = (ImageButton) findViewById(R.id.newTag); enabled_disabled = (TextView) findViewById(R.id.enabled_disabled); Switch toggle = (Switch) findViewById(R.id.toggle); seekBar = (SeekBar) findViewById(R.id.seekBar); progressBar = (ProgressBar) findViewById(R.id.progressBar); Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper); listView = (ListView) findViewById(R.id.listView); backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue); noTags = (TextView) findViewById(R.id.noTags); // Initialize TagAdapter adapter = new TagAdapter(this, tags); registerForContextMenu(listView); // Set listView adapter to TapAdapter object listView.setAdapter(adapter); // Set click, check and seekBar listeners setPin.setOnClickListener(this); newTag.setOnClickListener(this); refreshWallpaper.setOnClickListener(this); toggle.setOnCheckedChangeListener(this); seekBar.setOnSeekBarChangeListener(this); // Set seekBar progress to blur var try { seekBar.setProgress(settings.getInt("blur")); } catch (JSONException e) { e.printStackTrace(); } // Refresh the listView height updateListViewHeight(listView); // If no tags, show 'Press + to add Tags' textView if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); // Scroll up scrollView = (ScrollView) findViewById(R.id.scrollView); scrollView.post(new Runnable() { public void run() { scrollView.scrollTo(0, scrollView.getTop()); scrollView.fullScroll(View.FOCUS_UP); } }); // If lockscreen enabled, initialize switch, text and start service try { if (settings.getBoolean("lockscreen")) { onStart = true; enabled_disabled.setText(R.string.lockscreen_enabled); enabled_disabled.setTextColor(getResources().getColor(R.color.green)); toggle.setChecked(true); } } catch (JSONException e1) { e1.printStackTrace(); } }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING:// w w w. j a va2s.c o m setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:ro.ui.pttdroid.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from ww w.java2s.c o m getActionBar().setBackgroundDrawable(null); System.out.println("start main!!!!!!!!!!"); /* mContext = this.getApplicationContext(); spinner = (Spinner)findViewById(R.id.mySpinner); mContext2 = this.getApplicationContext(); spinner2 = (Spinner)findViewById(R.id.mySpinner2); lunchList = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch); spinner.setAdapter(lunchList); lunchList2 = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch2); spinner2.setAdapter(lunchList2); */ try { NfcManager managers = (NfcManager) getSystemService(Context.NFC_SERVICE); adapter = managers.getDefaultAdapter(); } catch (Exception e) { } try { ParseHelper.initParse(this); EventBus.getDefault().postSticky("Parse init success!"); } catch (Exception e) { EventBus.getDefault().postSticky("Failed to int parse!"); } loadAd(); init(); //writing = (ImageView) findViewById(R.id.writing); if (if_guider) { // writing.setVisibility(View.VISIBLE); // writing.setBackgroundResource(R.drawable.circle_green); } btn_test_mp3 = (Button) findViewById(R.id.btn_test_mp3); btn_test_mp3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Mp3Helper mp3Helper = new Mp3Helper("", ""); mp3Helper.test_start_converting(); } }); Button button = (Button) findViewById(R.id.force); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub test_socket_server(); } }); intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION); manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); channel = manager.initialize(this, getMainLooper(), null); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); EventBus.getDefault().register(this); // test_connect(); }
From source file:com.coinblesk.client.utils.UIUtils.java
private static boolean hasNFC(Context context) { NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); NfcAdapter adapter = manager.getDefaultAdapter(); return adapter != null; }
From source file:com.coinblesk.client.utils.UIUtils.java
private static boolean isNFCEnabled(Context context) { NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); NfcAdapter adapter = manager.getDefaultAdapter(); return adapter != null && adapter.isEnabled(); }
From source file:org.croudtrip.fragments.join.JoinDrivingFragment.java
private void switchToNfcIfAvailable() { NfcManager manager = (NfcManager) getActivity().getSystemService(Context.NFC_SERVICE); NfcAdapter adapter = manager.getDefaultAdapter(); if (adapter != null && adapter.isEnabled()) { // nfc exists and is enabled. ivNfcIcon.setVisibility(View.VISIBLE); tvNfcExplanation.setVisibility(View.VISIBLE); btnReachedDestination.setVisibility(View.GONE); }//from ww w. j a v a 2 s . c o m }