send Update Broadcast - Android android.app

Android examples for android.app:AlarmManager

Description

send Update Broadcast

Demo Code

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class Main{

    private static String CODE = "intent_code";

    public static void sendUpdateBroadcast(Context context, int time,
            String code) {/*from   ww  w.j a  v a2  s .c  o  m*/
        AlarmManager am = getAlarmManager(context);
        Intent i = new Intent(CODE);
        i.putExtra("code", code);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                0, i, 0);
        am.set(AlarmManager.RTC, System.currentTimeMillis() + time * 1000,
                pendingIntent);
    }

    public static AlarmManager getAlarmManager(Context context) {
        return (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
    }

}

Related Tutorials