Android服务的Onresume方法
我试图使一个服务,等待NFC标签,并做一些事情。我可以在活动中使用下面的代码块来实现它,但即使经过研究,也不知道如何在服务中实现它Android服务的Onresume方法,android,android-service,Android,Android Service,我试图使一个服务,等待NFC标签,并做一些事情。我可以在活动中使用下面的代码块来实现它,但即使经过研究,也不知道如何在服务中实现它 @Override protected void onResume() { super.onResume(); // Sticky notes received from Android if enableNdefExchangeMode(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(get
@Override
protected void onResume() {
super.onResume(); // Sticky notes received from Android if
enableNdefExchangeMode();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
do_something();
}
}
我想在服务中这样做。我无法使用super.onResume()。我应该用什么来代替这个,或者怎么做
任何帮助都将不胜感激。已经感谢您的帮助了给您:)
我还建议看一下这里:更多文档、示例和代码
<service
android:name="com.myexample.ServiceName" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/com.example.android.beam" />
</intent-filter>
</service>
给你:)
我还建议看一下这里:更多文档、示例和代码
<service
android:name="com.myexample.ServiceName" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/com.example.android.beam" />
</intent-filter>
</service>
谢谢你的回答,但我听不懂。我希望在我的活动开始时创建的服务等待NDEFèU发现的标记并执行某些操作。我在活动“只需服务”中实现了这一点。您需要知道如何绑定到服务吗?不需要,但我将在从其他设备获取消息后使用此示例。谢谢你的回答,但我听不懂。我希望在我的活动开始时创建的服务等待NDEFèU发现的标记并执行某些操作。我在活动“只需服务”中实现了这一点。您需要知道如何绑定到服务吗?不需要,但我将在从其他设备获取消息后使用此示例。