Java tutorial
//package com.java2s; //License from project: Open Source License import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.nfc.NfcAdapter; import android.os.Build; public class Main { @TargetApi(16) static void setAndroidBeam(Activity activity, String packageName) { if (Build.VERSION.SDK_INT < 16) return; 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(); } } } @TargetApi(14) private static NfcAdapter getAdapter(Context context) { if (Build.VERSION.SDK_INT < 14) return null; return NfcAdapter.getDefaultAdapter(context.getApplicationContext()); } }