gpt4 book ai didi

android - android 6.0重复闹钟的方法

转载 作者:太空狗 更新时间:2023-10-29 13:09:01 26 4
gpt4 key购买 nike

我正在使用 setExactAndAllowWhileIdle() 设置闹钟。但它只能使用一次。如何设置间隔为 1 天的重复闹钟?在 API 级别 23 setInexactRepeating 方法工作正常之前。

最佳答案

当广播接收器事件正在执行时为您的闹钟充电。

我的意思是,

public class CustomBroadcast extends WakefulBroadcastReceiver {
public static final String somekey = "somekey.somekey.somekey";
@Override
public void onReceive(Context ctx, Intent intent) {
// TODO Auto-generated method stub
ComponentName comp = new ComponentName(ctx.getPackageName(),
YourSevice.class.getName());
YourCustomClass.yourrechargefunction();
startWakefulService(ctx, intent.setComponent(comp));
}
}

public class YourCustomClass {
private final static int somekey_int = anynumber;
public static void yourrechargefunction() {
Intent intent = new Intent(CustomBroadcast.somekey):
PendingIntent pi = wPendingIntent.getBroadcast(ctx,somekey_int, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, nexttime, pi);
}
}

关于android - android 6.0重复闹钟的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43450427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com