English 中文(简体)
在"睡觉"和机器人装置上的警报火
原标题:Alarm fires on "sleeping" Android device
  • 时间:2012-05-24 15:08:19
  •  标签:
  • android

我正在写一个需要经常更新的 Android App AppParts (是的,我知道,不应该这样做,不管...) 。 我希望它只有在可见时才更新,但令人烦恼的是,它似乎与Wallpaper Servicice.Engine.on VisibilableChanged(bolean oblight) (可见) 毫无相似之处。

在此建议的方法是使用 AlarmManager. set Repeating (AarmManager.RTC, firstShot, 间距, 待定) 设置提醒, 触发每个 interval 毫秒的更新。 这至少不会在设备入睡时唤醒它 。

这正是我所做的。 我的 < code> pendingIntent 看起来像这个:

final Intent intent = new Intent(context, CountdownWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);

final PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

Countdown 元件服务 每次被提醒触发时都会记录一条消息。 日志消息即使在设备应入睡时也会出现, 但这正是我原以为不应该发生的。 我的错误在哪里?

最佳回答

也许您拥有的其他一些应用程序正在唤醒设备, 您的提醒会随之执行。 如果您使用 < code> AlarmManager. RTC , 意思是: 如果设备是醒着的, 或者等到它醒着之后再执行 。 check logcat to see what is happening and us this order to see what other wards registered:

adb shell dumpsys alarm
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签