我有一个应用程序,对我来说检测时间更改很重要。到目前为止,我已经与适当的意图过滤器接收这样的:即使应用关闭,如何获取时间更改广播
android:name=".MyReceiver"
android:enabled="true"
android:exported="true">
,这是我的接收器:
public class MyReceiver extends BroadcastReceiver {
public MyReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences.Editor spe =PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
spe.putLong("UFCount", 1));
spe.putLong("FCount", 1));
spe.commit();
Toast.makeText(context.getApplicationContext(), "Your job is being done!!", Toast.LENGTH_LONG).show();
}
}
这个接收器只有当应用程序被打开\在最后台运行。即使应用程序已关闭,我如何使此接收器工作?
2016-05-06
hadi
+0
您可以点击此链接[http://stackoverflow.com/a/16824692/4049612](http://stackoverflow.com/a/16824692/4049612) –
+0
@Krishna我不觉得有一个良好的服务始终运行。我不认为它是这样做的最佳方式 –