В моем коде менеджер тревог не работает. Остальное у меня работает нормально. Пожалуйста, посмотрите мой код.
Intent myIntent = new Intent(getApplicationContext(), AndroidAlarmService.class);
myIntent.putExtra("class", "home");
PendingIntent pendingIntent = PendingIntent.getService(this, 0,myIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),6000,pendingIntent);
и мой класс AlarmService для Android: -
public class AndroidAlarmService extends BroadcastReceiver implements URLs{
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
System.out.println("BroadCast\n");
String name=intent.getStringExtra("class");
if(name.equals("home")){
Intent homeIn=new Intent(context,Home.class);
context.startActivity(homeIn);
}
}
}
в манифесте я сделал это;
<receiver android:name=".AndroidAlarmService" android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"></action>
</intent-filter>
</receiver>
Почему не работает ??