List of usage examples for android.nfc NfcAdapter setBeamPushUris
@java.lang.Deprecated public void setBeamPushUris(Uri[] uris, Activity activity)
From source file:Main.java
@TargetApi(16) static void disableAndroidBeam(Activity activity) { if (Build.VERSION.SDK_INT < 16) return;//from w ww.j a v a2 s.c o m NfcAdapter nfcAdapter = getAdapter(activity); if (nfcAdapter != null) nfcAdapter.setBeamPushUris(null, activity); }
From source file:Main.java
/** * Sets up the NFC adapter to send a list of {@link Uri} with 'file' or 'content' scheme. To clear the NFC adapter * of the list of {@link Uri}, null should be passed as the second parameter. * * @param activity the {@link Activity}. * @param uris the list of {@link Uri} to beam. Pass null to clear NFC adapter. *//* w w w . ja v a2 s .c o m*/ public static void beamUris(Activity activity, Uri[] uris) { if (activity != null && !activity.isFinishing()) { NfcAdapter nfcAdapter = getNfcAdapter(activity); if (nfcAdapter != null) { try { nfcAdapter.setBeamPushUris(uris, activity); } catch (Exception e) { // Do nothing. An exception is thrown if a destroyed Activity is passed. } } } }
From source file:Main.java
@TargetApi(16) static void setAndroidBeam(Activity activity, String packageName) { if (Build.VERSION.SDK_INT < 16) return;/*from w w w .ja v a2s .co m*/ PackageManager pm = activity.getPackageManager(); NfcAdapter nfcAdapter = getAdapter(activity); if (nfcAdapter != null) { ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Uri uris[] = { Uri.parse("file://" + appInfo.publicSourceDir), }; nfcAdapter.setBeamPushUris(uris, activity); } catch (NameNotFoundException e) { e.printStackTrace(); } } }
From source file:com.android.gallery3d.app.PhotoPage.java
@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setupNfcBeamPush() { if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) return;// w w w . j a v a2 s . c o m NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mActivity); if (adapter != null) { adapter.setBeamPushUris(null, mActivity); /// M: [BEHAVIOR.MODIFY] nfc @{ if (FeatureConfig.SUPPORT_MTK_BEAM_PLUS) { adapter.setMtkBeamPushUrisCallback(new CreateBeamUrisCallback() { @Override public Uri[] createBeamUris(NfcEvent event) { return mNfcPushUris; } }, mActivity); } else { adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() { @Override public Uri[] createBeamUris(NfcEvent event) { return mNfcPushUris; } }, mActivity); } /*adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() { @Override public Uri[] createBeamUris(NfcEvent event) { return mNfcPushUris; } }, mActivity);*/ /// @} } }