标签:activity new gets roi pre ext extends ice realtime
package com.example.alarm; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class RefreshBroadcastReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Toast.makeText(context, "kym I love you", Toast.LENGTH_SHORT).show(); } }
package com.example.alarm; import android.os.Bundle; import android.app.Activity; import android.app.PendingIntent; import android.content.Intent; import android.app.AlarmManager; public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent2 = new Intent(this, RefreshBroadcastReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent2, 0); manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 100, 100, pi); } }
标签:activity new gets roi pre ext extends ice realtime
原文地址:https://www.cnblogs.com/cuthead/p/alarm.html