i need to make a shedule reminder which will notify every day at several specific times here just for example i am calling it twice but the twice call to setInexactRepeating is not working for me the notification i get is only because first call of setInexactRepeating please tell me what should i do
here is my code..
package aadil.reminder.health;
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
NotificationManager nm;
AlarmManager am;
Calendar clndr=Calendar.getInstance();
static final int unique=18493;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
am=(AlarmManager) getSystemService(ALARM_SERVICE);
//Toast.makeText(getApplicationContext(), "button clicked", Toast.LENGTH_LONG).show();
Intent intent = new Intent("intent.AADIL_INTENT");
intent.putExtra("msg", "blah blah");
intent.putExtra("msg", "class 2");
//intent.putExtra("msg1", "blah msg 2");
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), 1, intent, 0);
PendingIntent p2 = PendingIntent.getBroadcast(getApplicationContext(), 1, intent, 0);
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+2000,3000, pi);
//intent.putExtra("msg", "class 1");
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+3000,2000, p2);
}
}
package aadil.reminder.health;
public class AlarmReciever extends BroadcastReceiver {
int i = 0;
@Override
public void onReceive(Context arg0, Intent arg1) {
NotificationManager nm = (NotificationManager) arg0.getSystemService(arg0.NOTIFICATION_SERVICE);
Intent intent=new Intent().addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi= PendingIntent.getBroadcast(arg0, 0, intent, 0);
String body= arg1.getExtras().getString("msg");
String title="wake up";
Notification n=new Notification(R.drawable.ic_launcher, body, System.currentTimeMillis());
n.setLatestEventInfo(arg0, title, body, pi);
n.flags = n.flags | n.FLAG_AUTO_CANCEL;
n.defaults=Notification.DEFAULT_ALL;
nm.notify(i,n);
i++;
}
}