mirror of
https://github.com/bspeice/UNCCGameDay
synced 2025-07-05 15:55:08 -04:00
Add initial code to show alerts
This commit is contained in:
@ -1,20 +1,37 @@
|
||||
package com.uncc.gameday.activities;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.uncc.gameday.R;
|
||||
import com.uncc.gameday.alerts.AlertFetcher;
|
||||
import com.uncc.gameday.alerts.AlertService;
|
||||
|
||||
public class Home extends MenuActivity {
|
||||
|
||||
private final long alarmRate = 300000; // 5 Minutes
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
|
||||
// Start up the AlarmManager to fetch alerts in the background
|
||||
AlarmManager am = (AlarmManager) this.getSystemService(ALARM_SERVICE);
|
||||
Intent alertFetcher = new Intent(this, AlertService.class);
|
||||
PendingIntent pendingAlertFetcher = PendingIntent.getService(ctx, 0, alertFetcher, 0);
|
||||
|
||||
// Cancel any previous alarm managers, and start the new one
|
||||
am.cancel(pendingAlertFetcher);
|
||||
am.setRepeating(0, this.alarmRate, this.alarmRate, pendingAlertFetcher);
|
||||
|
||||
// Double check if we need to do any first-run code
|
||||
this.onFirstRun(ctx);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user