私はGoogle Playで2つの目覚まし時計アプリを開発しています。私は彼らにAndroid 6.0で作業させようとしています。しかし、ドーズモードでは、リングしないようにします。私はそれらをホワイトリストに載せ、フォアグラウンドの通知アイコンを上にして、何ができるか分かりません。Dozeモードでは、Alarm Managerのアラームは無視されます。ただし、時計アプリ(AOSPアプリではなくGoogle Play)は異なります。時計アプリでアラームが有効になっている場合、「adb deviceidle step」は常に「アクティブ」と表示され、「アイドル」、「idle_pending」などは表示されません。Android 6.0がDozeモードのときにAlarm Managerを動作させるにはどうすればいいですか?
Androidはここで不正行為をしていますが、自分のアプリにもっと力を与えています。 "リンゴを引っ張る"? Google Playのすべての目覚まし時計アプリが機能しなくなる予定ですか?ここで心配しているのは、パートタイムの開発時間を1年要した高品質のアプリで、私の大きな収入源です。どのように私はこれらを動作させることができるかについての手がかりは、大きな助けになるだろう。
Intent intent = new Intent(context, ReceiverAlarm.class);
if (android.os.Build.VERSION.SDK_INT >= 16) {
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
}
amSender = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT); //FLAG_CANCEL_CURRENT seems to be required to prevent a bug where the intent doesn't fire after app reinstall in KitKat
am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, scheduleToTime+1, amSender);
とReceiverAlarmクラス:
public class ReceiverAlarm extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (wakeLock == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Theme.appTitle);
wakeLock.acquire();
}
X.alarmMaster.startRingingAlarm(true);
}
とX.alarmMaster.startRingingAlarmの関連部分()メソッド:
if (wakeLock == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Theme.appTitle);
wakeLock.acquire();
}
if (screenWakeLock == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
screenWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, Theme.appTitle+" scr");
screenWakeLock.acquire();
}
Intent alarmIntent = new Intent(Intent.ACTION_VIEW);
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
alarmIntent.setClass(context, ActivityAlarmAlarm.class);
context.startActivity(alarmIntent);
AlarmManager意図を設定
いくつかのメソッドは、読みやすくするためにインラインで貼り付けられています。
他の人が何が起こっているか見るのを助けることができるいくつかのスニペットを持っています。してください:-) – Nabin
確かに、私は私の応答を編集します。それらは両方とも20k +コード行ですので、私はそれらの1つの関連する行を投稿しようとします。 – user1908060