如何在不打开应用程序运行Android程序? [英] How to run android program without open the app?
问题描述
我的应用程序可以通过NFC打开,然后利用这些信息在标签做一些处理,处理约5秒。
My app can be opened by NFC, and then use the information in the tag to do some processing, the processing is around 5 seconds.
如果我的应用程序是通过NFC开了,我不希望它显示在屏幕上。所以这是的onCreate。
If my app is opened by NFC, I don't want it shows on screen. So this is the 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秒钟。
But it is not work, the app will shows on screen about 5 seconds.
即使我不处理任何
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
this.finish();
System.exit(0);
}
我仍然可以看到在很短的时间内该应用程序屏幕。
I still can see the app screen in very short time.
如何prevent该应用显示屏幕,如果我使用NFC来运行呢?
How to prevent the app to show the screen if I use NFC to run it?
推荐答案
在你的manifest.xml您可以指定设置下列主题的活动:
In your manifest.xml you can specify set the following theme for your activity:
安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar
这使你的活动不可见(如果它是空的)。
This makes your activity invisible (if it's empty).
这篇关于如何在不打开应用程序运行Android程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!