@ReactMethod private void registerTagEvent(String alertMessage, Boolean invalidateAfterFirstRead, Callback callback) { Log.d(LOG_TAG, "registerTag"); isForegroundEnabled = true; // capture all mime-based dispatch NDEF IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } intentFilters.add(ndef); // capture all rest NDEF, such as uri-based intentFilters.add(new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED)); techLists.add(new String[]{Ndef.class.getName()}); // for those without NDEF, get them as tags intentFilters.add(new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED)); if (isResumed) { enableDisableForegroundDispatch(true); } callback.invoke(); }
public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { final Intent intent = new Intent(activity.getApplicationContext(), ReadCardActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][]{}; filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType("*/*"); //TODO Use only needed MIME based dispatches. } catch (MalformedMimeTypeException e) { throw new RuntimeException("MIME type not supported."); } adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); }
/** * Constructs an intent filter from user input. This intent-filter is used for cross-profile * intent. * * @return a user constructed intent filter. */ private IntentFilter getIntentFilter() { if (mActions.isEmpty() && mCategories.isEmpty() && mDataSchemes.isEmpty() && mDataTypes.isEmpty()) { return null; } IntentFilter intentFilter = new IntentFilter(); for (String action : mActions) { intentFilter.addAction(action); } for (String category : mCategories) { intentFilter.addCategory(category); } for (String dataScheme : mDataSchemes) { intentFilter.addDataScheme(dataScheme); } for (String dataType : mDataTypes) { try { intentFilter.addDataType(dataType); } catch (MalformedMimeTypeException e) { Log.e(TAG, "Malformed mime type: " + e); return null; } } return intentFilter; }
/** * @param activity The corresponding {@link Activity} requesting the foreground dispatch. * @param adapter The {@link NfcAdapter} used for the foreground dispatch. */ public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][]{}; // Notice that this is the same filter as in our manifest. filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType(MIME_TEXT_PLAIN); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Check your mime type."); } adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); }
public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { final Intent intent = new Intent(activity.getApplicationContext(),activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][] {}; filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType(MIME_TEXT_PLAIN); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Check your mime type."); } adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); }
public void onCreate(Bundle savedInstanceState) { // setup NFC // http://stackoverflow.com/questions/5685946/nfc-broadcastreceiver-problem // http://stackoverflow.com/questions/5685770/nfc-intent-get-info-from-the-tag // NOTE on devices without NFC, this method call returns NULL mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity); mNfcPendingIntent = PendingIntent.getActivity(mActivity, 0, new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); try { tech.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mNfcFilters = new IntentFilter[] { tech }; // Mifare Classic are also NfcA, but in contrary to NfcA, MifareClassic support is optional // http://developer.android.com/reference/android/nfc/tech/MifareClassic.html mNfcTechLists = new String[][] { new String[] { NfcA.class.getName() } }; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); setContentView(R.layout.main); findViewById(R.id.write_tag).setOnClickListener(mTagWriter); mNote = ((EditText) findViewById(R.id.note)); mNote.addTextChangedListener(mTextWatcher); // Handle all of our received NFC intents in this activity. mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Intent filters for reading a note from a tag or exchanging over p2p. IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("text/plain"); } catch (MalformedMimeTypeException e) { } mNdefExchangeFilters = new IntentFilter[] { ndefDetected }; // Intent filters for writing to a tag IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); mWriteTagFilters = new IntentFilter[] { tagDetected }; }
private void _init() { _nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (_nfcAdapter == null) { Toast.makeText(this, "This device does not support NFC.", Toast.LENGTH_LONG).show(); return; } if (_nfcAdapter.isEnabled()) { _pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType(_MIME_TYPE); } catch (MalformedMimeTypeException e) { Log.e(this.toString(), e.getMessage()); } _intentFilters = new IntentFilter[] { ndefDetected }; } }
private void _init() { _nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (_nfcAdapter == null) { Toast.makeText(this, "This device does not support NFC.", Toast.LENGTH_LONG).show(); return; } if (_nfcAdapter.isEnabled()) { _pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType(_MIME_TYPE); } catch (MalformedMimeTypeException e) { Log.e(this.toString(), e.getMessage()); } _readIntentFilters = new IntentFilter[] { ndefDetected }; } }
public void setupForegroundDispatch(Activity activity) { final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity( activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][] {}; // Notice that this is the same filter as in our manifest. filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType(MIME_TEXT_PLAIN); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Check your mime type."); } nfcAdapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.beamer); mInfoText = (TextView) findViewById(R.id.mInfo); writeText = (EditText) findViewById(R.id.textWrite); // Check for available NFC Adapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null) { mInfoText = (TextView) findViewById(R.id.mInfo); mInfoText.setText("NFC is not available on this device."); } mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Intent filters for exchanging over p2p. IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("*/*"); } catch (MalformedMimeTypeException e) { Toast.makeText(getApplicationContext(), "Error Exception", Toast.LENGTH_SHORT).show(); } mNdefExchangeFilters = new IntentFilter[] { ndefDetected, }; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); setContentView(R.layout.main); findViewById(R.id.write_tag).setOnClickListener(mTagWriter); // Handle all of our received NFC intents in this activity. mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Intent filters for reading a note from a tag or exchanging over p2p. IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("text/plain"); } catch (MalformedMimeTypeException e) { } mNdefExchangeFilters = new IntentFilter[] { ndefDetected }; // Intent filters for writing to a tag IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); mWriteTagFilters = new IntentFilter[] { tagDetected }; }
/** * @return Registration id to use in unregister(regId) method */ public static synchronized int register(String receiverId, EventsListener listener) { check(); if (listener == null) throw new NullPointerException("Listener cannot be null"); EventsReceiver receiver = new EventsReceiver(); receiver.mReceiverId = receiverId; receiver.mListener = listener; try { sAppContext.registerReceiver(receiver, new IntentFilter(sIntentAction, BASE_MIME_TYPE + "/*")); } catch (MalformedMimeTypeException e) { e.printStackTrace(); } sReceiversMap.put(++sRegistrationId, receiver); for (Intent sticky : sStickyEventsMap.values()) { receiver.onReceive(sAppContext, sticky); } return sRegistrationId; }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); Intent intent = new Intent(getActivity(), getActivity().getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); mPendingIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0); mTechLists = new String[][] {new String[] {MifareClassic.class.getName()}}; IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] {ndef}; setButtonVisibility(true); }
private void removeMimeType(JSONArray data, CallbackContext callbackContext) throws JSONException { String mimeType = ""; try { mimeType = data.getString(0); /*boolean removed =*/ removeIntentFilter(mimeType); callbackContext.success(); } catch (MalformedMimeTypeException e) { callbackContext.error("Invalid MIME Type " + mimeType); } }
private void registerMimeType(JSONArray data, CallbackContext callbackContext) throws JSONException { String mimeType = ""; try { mimeType = data.getString(0); intentFilters.add(createIntentFilter(mimeType)); callbackContext.success(); } catch (MalformedMimeTypeException e) { callbackContext.error("Invalid MIME Type " + mimeType); } }
private boolean removeIntentFilter(String mimeType) throws MalformedMimeTypeException { boolean removed = false; Iterator<IntentFilter> iter = intentFilters.iterator(); while (iter.hasNext()) { IntentFilter intentFilter = iter.next(); String mt = intentFilter.getDataType(0); if (mimeType.equals(mt)) { intentFilters.remove(intentFilter); removed = true; } } return removed; }
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.foreground_dispatch); mText = (TextView) findViewById(R.id.text); mText.setText("Scan a tag"); mAdapter = NfcAdapter.getDefaultAdapter(this); // Create a generic PendingIntent that will be deliver to this activity. The NFC stack // will fill in the intent with the details of the discovered tag before delivering to // this activity. mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter for all MIME based dispatches IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] { ndef, }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create NFC Adapter mAdapter = NfcAdapter.getDefaultAdapter(this); // Pending intent mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, ScanActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter for all MIME based dispatches (TEXT); IntentFilter ndefText = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefText.addDataType("*/*"); } catch (MalformedMimeTypeException e) { } // Setup an intent filter for all MIME based dispatches (URI); IntentFilter ndefURI = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); ndefURI.addDataScheme("http"); ndefURI.addDataScheme("https"); mFilters = new IntentFilter[] { ndefText, ndefURI}; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; }
public IntentFilter[] getIntentFilter(String action, String category, String mimeType) { IntentFilter filter = new IntentFilter(); if(action != null) filter.addAction(action); if(category != null) filter.addCategory(category); if(mimeType != null) { try { filter.addDataType(mimeType); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Error handling MIME type."); } } return new IntentFilter[] { filter }; }
public final void a(Bundle paramBundle) { super.a(paramBundle); this.ac = this.m.getString("square_id"); if (paramBundle != null) { this.ag = ((Uri)paramBundle.getParcelable("uploading_image_uri")); this.ah = ((Uri)paramBundle.getParcelable("current_data")); this.Z = ((ipf)paramBundle.getParcelable("selected_user_photo")); this.b = ((RectF)paramBundle.getParcelable("CROP_COORDINATES")); } mbf localmbf = this.bn; if (lcm.a == null) { IntentFilter localIntentFilter = new IntentFilter(); lcm.a = localIntentFilter; localIntentFilter.addAction("com.google.android.libraries.social.squares.edit.UPLOAD_PROGRESS"); } try { lcm.a.addDataType("image/*"); fy.a(localmbf.getApplicationContext()).a(new lcn(this), lcm.a); return; } catch (IntentFilter.MalformedMimeTypeException localMalformedMimeTypeException) { for (;;) { Log.e("UploadSquarePhotoTask", "MIME type cannot be recognized."); } } }
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.foreground_dispatch); mText = (TextView) findViewById(R.id.text); mText.setText("Scan a tag"); mAdapter = NfcAdapter.getDefaultAdapter(this); // Create a generic PendingIntent that will be deliver to this activity. The NFC stack // will fill in the intent with the details of the discovered tag before delivering to // this activity. mPendingIntent = org.bbs.apklauncher.emb.PendingIntentHelper.getActivity(this, 0, new org.bbs.apklauncher.emb.IntentHelper(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter for all MIME based dispatches IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] { ndef, }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; }
/** * @param activity * The corresponding {@link Activity} requesting the foreground * dispatch. * @param adapter * The {@link NfcAdapter} used for the foreground dispatch. */ public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity( activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][] {}; // Notice that this is the same filter as in our manifest. filters[0] = new IntentFilter(); filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { filters[0].addDataType(MIME_PUBLIC_KEY); filters[0].addDataType(MIME_TEXT_PLAIN); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Check your mime type."); } adapter .enableForegroundDispatch(activity, pendingIntent, filters, techList); }
private static void addDataTypeUnchecked(IntentFilter filter, String type) { try { filter.addDataType(type); } catch (MalformedMimeTypeException ex) { throw new RuntimeException(ex); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dump_raw); // Show the Up button in the action bar. setupActionBar(); mAdapter = NfcAdapter.getDefaultAdapter(this); mPendingIntent = PendingIntent.getActivity( this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter for all MIME based dispatches IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } IntentFilter td = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); mFilters = new IntentFilter[] { ndef, td }; // Setup a tech list for all NfcF tags mTechLists = new String[][] { new String[] { /*NfcV.class.getName(), NfcF.class.getName(),*/ NfcA.class.getName(), //NfcB.class.getName() } }; txtRaw = (TextView) findViewById(R.id.txtRaw); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); findViewById(R.id.write_tag).setOnClickListener(mTagWriter); mNote = ((EditText) findViewById(R.id.note)); mNote.addTextChangedListener(mTextWatcher); // Handle all of our received NFC intents in this activity. mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Intent filters for reading a note from a tag or exchanging over p2p. IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("text/plain"); } catch (MalformedMimeTypeException e) { Log.d(TAG, "Failed to addDataType"); } mNdefExchangeFilters = new IntentFilter[]{ndefDetected}; // Intent filters for writing to a tag IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); mWriteTagFilters = new IntentFilter[]{tagDetected}; }
public IntentFilter buildFilter(){ Log.i(TAG,"buildFilter()"); IntentFilter filter = new IntentFilter(DispatchResponseReceiver.BROADCAST_RESPONSE); filter.addDataScheme(Encounters.CONTENT_URI.getScheme()); try { filter.addDataType(Encounters.CONTENT_ITEM_TYPE); } catch (MalformedMimeTypeException e) { } return filter; }
public IntentFilter buildFilter(){ IntentFilter filter = new IntentFilter(Response.RESPONSE); try{ filter.addDataType(EncounterTasks.CONTENT_TYPE); filter.addDataType(EncounterTasks.CONTENT_ITEM_TYPE); filter.addDataType(Subjects.CONTENT_TYPE); } catch (MalformedMimeTypeException e) { } return filter; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndef1 = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); //IntentFilter ndef2 = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); mFilters = new IntentFilter[] { ndef1, //ndef2, }; try { ndef1.addDataType("*/*"); //ndef2.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mAdapter = NfcAdapter.getDefaultAdapter(this); if (getIntent() != null){ resolveIntent(getIntent()); } }
protected IntentFilter getIntentFilter() throws MalformedMimeTypeException { IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); filter.addDataScheme("http"); filter.addDataAuthority("beta.leankeen.com", null); filter.addDataAuthority("www.leankeen.com", null); filter.addDataAuthority("www.flingtap.com", null); filter.addDataAuthority("market.android.com", null); return filter; }
private void resetForegroundDispatcher() { nfcAdapter.disableForegroundDispatch(this); if (!readRtdOnly) { nfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, null, null); Log.i(DEBUG_MAIN_ACTIVITY, "Listening for any type of tag scan"); } else { IntentFilter rtdFilter = new IntentFilter( NfcAdapter.ACTION_NDEF_DISCOVERED); try { rtdFilter.addDataType("text/plain"); } catch (MalformedMimeTypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } IntentFilter[] filters = new IntentFilter[] { rtdFilter }; nfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, filters, null); Log.i(DEBUG_MAIN_ACTIVITY, "Listening only for an RTD_TEXT NDEF record on a tag"); } }
private void prepareNFC() { IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("application/vnd.serpro.nfcevents"); } catch (MalformedMimeTypeException e) { } mNdefExchangeFilters = new IntentFilter[] { ndefDetected }; mNfcAdapter = NfcAdapter.getDefaultAdapter(this); mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); }
public static IntentFilter[] getIntentFilterArray() { IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType(SONY_MIME_TYPE); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } return new IntentFilter[]{ndef}; }
public GeoTrackOverlay(final Context ctx, final MapView mapView, final ResourceProxy pResourceProxy, LoaderManager loaderManager, Person person, long timeInMs, GeotrackLastAddedListener geotrackLastAddedListener) { super(pResourceProxy); GEOTRACK_LIST_LOADER = R.id.config_id_geotrack_list_loader + (int) person.id + 1000; // person.id; Log.d(TAG, "#################################"); Log.d(TAG, "### Create " + person); Log.d(TAG, "#################################"); this.context = ctx; this.person = person; this.loaderManager = loaderManager; this.mapView = mapView; this.mMapController = mapView.getController(); setDateRange(timeInMs); // Service this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); enableThreadExecutors(); if (Geocoder.isPresent()) { this.geocoder = new Geocoder(context, Locale.getDefault()); } else { this.geocoder = null; Log.w(TAG, "The Geocoder is not Present"); } // Listener this.geotrackLastAddedListener = geotrackLastAddedListener; mStatusReceiver = new StatusReceiver(); try { mStatusReceiverIntentFilter = new IntentFilter(Intents.ACTION_NEW_GEOTRACK_INSERTED, GeoTrackerProvider.Constants.ITEM_MIME_TYPE); } catch (MalformedMimeTypeException e) { Log.e(TAG, "Coud not create Intenfilter for mStatusReceiver : " + e.getMessage(), e); } // Init initDirectionPaint(person.color); onResume(); }