Isuues报警经理每隔1分钟的Andr​​oid

Isuues报警经理每隔1分钟的Andr​​oid

本文介绍了Isuues报警经理每隔1分钟的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个服务,火警经理每隔1分钟interval..But 我报警运行一次(仅第一次)。我按照拉利特回答

 私有类接收器扩展的BroadcastReceiver {

        @覆盖
        公共无效的onReceive(上下文的背景下,意图意图){

            Toast.makeText(getBaseContext(),报警,Toast.LENGTH_LONG).show();
            的NetworkInfo信息= intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
            AlarmManager经理=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
            意图I =新的意图(背景下,ConnectionReceiver.class);
            PendingIntent圆周率= PendingIntent.getBroadcast(上下文,0,I,0);
            mgr.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis的(),1 * 60 * 1000,PI);
        }
}
 

解决方案

伸出注册广播接收器:

i want to make a service which fire alarm manager in every 1 min interval..But my Alarm run once(first time only).i follow Lalit Answer

private class Receiver extends BroadcastReceiver{

        @Override
        public void onReceive(Context context, Intent intent) {

            Toast.makeText(getBaseContext(), "Alarm", Toast.LENGTH_LONG).show();
            NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
            AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
            Intent i=new Intent(context, ConnectionReceiver.class);
            PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0);
            mgr.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1*60*1000, pi);
        }
}
解决方案

Juts register broadcast receiver for:

http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK

这篇关于Isuues报警经理每隔1分钟的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:04