相关疑难解决方法(0)

每24小时和上午8点准确的时间点火

我AlarmManager()用来点火通知,每24小时重复一次.

我的代码onCreate()在Splash Activity中,当任何人打开App时,它会首先触发.用户可以随时安装App.所以我希望当用户安装应用程序时,它会检查时间,然后在上午8点触发通知并每天重复.当有人打开App时我不想要通知.

我的代码如下:

public class Splash extends Activity {

final String WebsiteURL = "http://www.mytestbuddy.com";

String cookie;

@SuppressLint("SimpleDateFormat")
@Override
protected void onCreate(Bundle showSplash) {
    // TODO Auto-generated method stub
    super.onCreate(showSplash);
    setContentView(R.layout.splash);

    getWindow().getDecorView().setBackgroundColor(Color.WHITE);

    Intent myIntent = new Intent(Splash.this, AlarmReceiver.class);

    final PendingIntent pendingIntent = PendingIntent.getBroadcast(
            Splash.this, 0, myIntent, 0);

    final AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    CookieSyncManager.createInstance(this);
    CookieManager cm = CookieManager.getInstance();
    cm.setAcceptCookie(true);
    CookieSyncManager.getInstance().sync();
    if (cm.getCookie("" + WebsiteURL + "") != null) {
        cookie = cm.getCookie("" + WebsiteURL + "").toString(); …
Run Code Online (Sandbox Code Playgroud)

android alarmmanager

21
推荐指数
2
解决办法
2万
查看次数

标签 统计

alarmmanager ×1

android ×1