Back to project page JavNav.
The source code is released under:
GNU General Public License
If you think the Android project JavNav listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* */*w w w. j a v a 2 s. c o m*/ * JavNav * a simple application for general use of the Texas A&M-Kingsville Campus. * * Copyright (C) 2014 Manuel Gonzales Jr. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. * */ package com.senior.javnav; //Android imports import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; public class BroadcastNews extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent arg1) { SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(arg0.getApplicationContext()); if(arg1.toString().contains(Intent.ACTION_BOOT_COMPLETED) && shared.getBoolean("notifi", false)) { //one second * 60 seconds in a minute * 5 long fiveMinutes = 1000*60*5; Intent service = new Intent(arg0, BroadcastNews.class); PendingIntent pendingService = PendingIntent.getBroadcast(arg0, 0, service, 0); AlarmManager newsUpdate = (AlarmManager)arg0.getSystemService(arg0.ALARM_SERVICE); //Check for the update every 5 minutes newsUpdate.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), fiveMinutes, pendingService); SharedPreferences.Editor edit = shared.edit(); edit.putBoolean("notifiCancelled", false); edit.commit(); Log.i("JavBroadcast","JavService started"); } else { //Starting the news update class Intent newsUpdate = new Intent(arg0,NewsUpdate.class); arg0.startService(newsUpdate); Log.i("JavBroadcast","Broadcast finished"); } } }