我用的软件是:macrodroid
手机是红米k50
很怪,每次执行都要点击“打开”
望采纳,谢谢!
1、可以使用Android的Foreground Dispatch系统来自动执行检测到的NFC标签,无需再点确认。Foreground Dispatch系统允许应用程序注册一个intent-filter,以便在检测到NFC标签时自动启动应用程序。应用程序可以使用PendingIntent类来定义要在检测到NFC标签时执行的操作。
2、要自动执行检测到的NFC标签,需要在应用中实现NFC标签的自动处理功能。
<uses-permission android:name="android.permission.NFC" />
public class MyNfcHandler extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
nfcAdapter.enableForegroundDispatch(this, new Intent(this, MyNfcHandler.class), null, null);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
// 在这里处理NFC标签
}
}
<activity android:name=".MyNfcHandler">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
以上就是实现自动执行检测到的NFC标签的步骤,无需再点击确认按钮。
不知道你这个问题是否已经解决, 如果还没有解决的话: