NFC可以打开我的应用程序,然后使用标记中的信息进行一些处理,处理大约需要5秒钟。
如果我的应用是由NFC打开的,则我不希望它在屏幕上显示。这就是onCreate。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.ab.R.layout.test);
Intent intent=getIntent();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
Log.v("nfc", "Start processing");
SystemClock.sleep(5000); // simulate the processing
Log.v("nfc", "End processing");
this.finish();
System.exit(0);
}
}
但这是行不通的,该应用将在屏幕上显示约5秒钟。
即使我什么都不处理
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
this.finish();
System.exit(0);
}
我仍然可以在很短的时间内看到应用程序屏幕。
如果我使用NFC运行该应用程序,如何防止该应用程序显示屏幕?
在manifest.xml中,您可以为活动指定以下主题:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
这会使您的活动不可见(如果为空)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句