有人可以帮助我吗?
这是我的警报管理员代码,每隔2秒就会打开一次服务..
AlarmManager alarmManager =
(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), 2*1000 , pintent);
这是我检查正在运行的应用程序的代码
ActivityManager activityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
for(int i = 0; i < procInfos.size(); i++){
if((procInfos.get(i).processName.equals("com.android.browser")
&& procInfos.get(i).importance==procInfos.get(i).IMPORTANCE_FOREGROUND)) {
Toast.makeText(getApplicationContext(), "Browser is running",
Toast.LENGTH_LONG).show();
问题是当浏览器打开时,每隔2秒就会出现一次吐司。当浏览器获得前景时,我应该如何只显示一次?真的需要一些帮助
谢谢!