当前位置: 首页>>代码示例>>Java>>正文


Java IntentFilter.addDataType方法代码示例

本文整理汇总了Java中android.content.IntentFilter.addDataType方法的典型用法代码示例。如果您正苦于以下问题:Java IntentFilter.addDataType方法的具体用法?Java IntentFilter.addDataType怎么用?Java IntentFilter.addDataType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.IntentFilter的用法示例。


在下文中一共展示了IntentFilter.addDataType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerTagEvent

import android.content.IntentFilter; //导入方法依赖的package包/类
@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();
	}
 
开发者ID:whitedogg13,项目名称:react-native-nfc-manager,代码行数:27,代码来源:NfcManager.java

示例2: enableForwarding

import android.content.IntentFilter; //导入方法依赖的package包/类
/**
 * Enables forwarding of share intent between private account and managed profile.
 */
private void enableForwarding() {
    Activity activity = getActivity();
    if (null == activity || activity.isFinishing()) {
        return;
    }
    DevicePolicyManager manager =
            (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
    try {
        IntentFilter filter = new IntentFilter(Intent.ACTION_SEND);
        filter.addDataType("text/plain");
        filter.addDataType("image/jpeg");
        // This is how you can register an IntentFilter as allowed pattern of Intent forwarding
        manager.addCrossProfileIntentFilter(BasicDeviceAdminReceiver.getComponentName(activity),
                filter, FLAG_MANAGED_CAN_ACCESS_PARENT | FLAG_PARENT_CAN_ACCESS_MANAGED);
    } catch (IntentFilter.MalformedMimeTypeException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:22,代码来源:BasicManagedProfileFragment.java

示例3: initializeNFC

import android.content.IntentFilter; //导入方法依赖的package包/类
public void initializeNFC() {

        if (nfcInit == false) {
            PackageManager pm = getPackageManager();
            nfcSupported = pm.hasSystemFeature(PackageManager.FEATURE_NFC);

            if (nfcSupported == false) {
                return;
            }

            // when is in foreground
            MLog.d(TAG, "starting NFC");
            mAdapter = NfcAdapter.getDefaultAdapter(this);

            // PedingIntent will be delivered 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 (IntentFilter.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()}};
            nfcInit = true;
        }
    }
 
开发者ID:victordiaz,项目名称:phonk,代码行数:32,代码来源:AppRunnerActivity.java

示例4: onCreate

import android.content.IntentFilter; //导入方法依赖的package包/类
@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() } };
}
 
开发者ID:appledong,项目名称:AndroidthingsStudy,代码行数:31,代码来源:ForegroundDispatch.java

示例5: createIntentFilter

import android.content.IntentFilter; //导入方法依赖的package包/类
private IntentFilter createIntentFilter(String mimeType) throws MalformedMimeTypeException {
    IntentFilter intentFilter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    intentFilter.addDataType(mimeType);
    return intentFilter;
}
 
开发者ID:theGreatWhiteShark,项目名称:mensacard-hack,代码行数:6,代码来源:NfcPlugin.java


注:本文中的android.content.IntentFilter.addDataType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。