本文整理匯總了Java中android.nfc.NfcAdapter.setBeamPushUris方法的典型用法代碼示例。如果您正苦於以下問題:Java NfcAdapter.setBeamPushUris方法的具體用法?Java NfcAdapter.setBeamPushUris怎麽用?Java NfcAdapter.setBeamPushUris使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.nfc.NfcAdapter
的用法示例。
在下文中一共展示了NfcAdapter.setBeamPushUris方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAndroidBeam
import android.nfc.NfcAdapter; //導入方法依賴的package包/類
@TargetApi(16)
public 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 (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Could not get application info", e);
}
}
}
示例2: disableAndroidBeam
import android.nfc.NfcAdapter; //導入方法依賴的package包/類
@TargetApi(16)
static void disableAndroidBeam(Activity activity) {
if (Build.VERSION.SDK_INT < 16) {
return;
}
NfcAdapter nfcAdapter = getAdapter(activity);
if (nfcAdapter != null) {
nfcAdapter.setBeamPushUris(null, activity);
}
}