在我的应用程序中,我有一项服务,例如在30秒后,运行另一项活动。我使用Alarm Manager完成了这个过程。
但问题是,如果用户更改系统时间,则会影响30秒。你的建议是什么?有没有办法知道用户是否更改了系统时间?
答案 0 :(得分:3)
您可以收听Intent.ACTION_DATE_CHANGED
广播。您的ApplicationManifest文件应包含类似
<receiver android:name="com.test.YouBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.DATE_CHANGED" >
</action>
<category android:name="android.intent.category.DEFAULT" >
</category>
</intent-filter>
</receiver>
对于广播接收者,请参阅:
http://developer.android.com/reference/android/content/BroadcastReceiver.html