List of usage examples for android.content Intent EXTRA_ALARM_COUNT
String EXTRA_ALARM_COUNT
To view the source code for android.content Intent EXTRA_ALARM_COUNT.
Click Source Link
From source file:com.meiste.greg.ptw.WidgetProvider.java
@Override public void onReceive(final Context context, final Intent intent) { if (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)) { Util.log("WidgetProvider.onReceive: Widget alarm"); new UpdateWidgetThread(context).start(); setAlarm(context);//from ww w . j a v a 2s. c o m } else if (intent.getAction().equals(Intent.ACTION_TIME_CHANGED)) { Util.log("WidgetProvider.onReceive: Time change"); setAlarm(context); } else if (intent.getAction().equals(PTW.INTENT_ACTION_SCHEDULE)) { Util.log("WidgetProvider.onReceive: Schedule Updated"); final int[] appWidgetIds = getInstalledWidgets(context); if (appWidgetIds.length > 0) { /* Force full widget update */ sRace = null; onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds); } } else if (intent.getAction().equals(PTW.INTENT_ACTION_ANSWERS)) { Util.log("WidgetProvider.onReceive: Answers submitted"); final int[] appWidgetIds = getInstalledWidgets(context); if (appWidgetIds.length > 0) { new UpdateWidgetThread(context).start(); } } else super.onReceive(context, intent); }
From source file:com.umaps.gpslogger.GpsLoggingService.java
private void HandleIntent(Intent intent) { GetPreferences();//from w w w . j av a 2 s. c om ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return; } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { Log.i(TAG, "Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { Log.i(TAG, "Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { Log.i(TAG, "Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); } if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { Log.i(TAG, "Intent received - Get Next Point"); needToStartGpsManager = true; } if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { Log.i(TAG, "Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault() .post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); Log.d(TAG, "Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); List<String> listeners = Utilities.GetListeners(); if (preferCellTower) { listeners.remove(listeners.indexOf("gps")); } else { listeners.remove(listeners.indexOf("network")); listeners.remove(listeners.indexOf("passive")); } Set<String> listenersSet = new HashSet<String>(listeners); prefs.edit().putStringSet("listeners", listenersSet).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); Log.d(TAG, "Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); prefs.edit().putString("time_before_logging", String.valueOf(timeBeforeLogging)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); Log.d(TAG, "Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); prefs.edit().putString("distance_before_logging", String.valueOf(distanceBeforeLogging)) .apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); Log.d(TAG, "Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); prefs.edit().putBoolean("keep_fix", keepBetweenFix).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); Log.d(TAG, "Intent received - Set Retry Time: " + String.valueOf(retryTime)); prefs.edit().putString("retry_time", String.valueOf(retryTime)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absolumeTimeOut = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); Log.d(TAG, "Intent received - Set Retry Time: " + String.valueOf(absolumeTimeOut)); prefs.edit().putString("absolute_timeout", String.valueOf(absolumeTimeOut)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); Log.d(TAG, "Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; //LogOnce(); } try { if (bundle.get(Intent.EXTRA_ALARM_COUNT) != "0") { needToStartGpsManager = true; } } catch (Throwable t) { Log.w(TAG, "Received a weird EXTRA_ALARM_COUNT value. Cannot continue."); needToStartGpsManager = false; } if (needToStartGpsManager && Session.isStarted()) { StartGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. Log.d(TAG, "Service restarted with null intent. Start logging."); StartLogging(); } }
From source file:org.ozonecity.gpslogger2.GpsLoggingService.java
private void HandleIntent(Intent intent) { GetPreferences();/*from w ww. ja v a 2 s. c o m*/ ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return; } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { tracer.info("Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { tracer.info("Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { tracer.debug("Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); } if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { tracer.debug("Intent received - Get Next Point"); needToStartGpsManager = true; } if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { tracer.debug("Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault() .post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); tracer.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); List<String> listeners = Utilities.GetListeners(); if (preferCellTower) { listeners.remove(listeners.indexOf("gps")); } else { listeners.remove(listeners.indexOf("network")); listeners.remove(listeners.indexOf("passive")); } Set<String> listenersSet = new HashSet<String>(listeners); prefs.edit().putStringSet("listeners", listenersSet).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); tracer.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); prefs.edit().putString("time_before_logging", String.valueOf(timeBeforeLogging)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); tracer.debug("Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); prefs.edit().putString("distance_before_logging", String.valueOf(distanceBeforeLogging)) .apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); tracer.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); prefs.edit().putBoolean("keep_fix", keepBetweenFix).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); tracer.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime)); prefs.edit().putString("retry_time", String.valueOf(retryTime)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absolumeTimeOut = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); tracer.debug("Intent received - Set Retry Time: " + String.valueOf(absolumeTimeOut)); prefs.edit().putString("absolute_timeout", String.valueOf(absolumeTimeOut)).apply(); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); tracer.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; LogOnce(); } if (bundle.getInt(Intent.EXTRA_ALARM_COUNT) != 0) { needToStartGpsManager = true; } if (needToStartGpsManager && Session.isStarted()) { StartGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. tracer.debug("Service restarted with null intent. Start logging."); StartLogging(); } }
From source file:com.mendhak.gpslogger.GpsLoggingService.java
private void handleIntent(Intent intent) { ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return;/* www. jav a 2s . c om*/ } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { LOG.info("Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { LOG.info("Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { LOG.info("Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); } if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { LOG.info("Intent received - Get Next Point"); needToStartGpsManager = true; } if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { LOG.info("Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault() .post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); } if (bundle.getString(IntentConstants.SWITCH_PROFILE) != null) { LOG.info("Intent received - switch profile: " + bundle.getString(IntentConstants.SWITCH_PROFILE)); EventBus.getDefault().post( new ProfileEvents.SwitchToProfile(bundle.getString(IntentConstants.SWITCH_PROFILE))); } if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); LOG.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); if (preferCellTower) { preferenceHelper.setChosenListeners(0); } else { preferenceHelper.setChosenListeners(1, 2); } needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); LOG.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); preferenceHelper.setMinimumLoggingInterval(timeBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); LOG.debug("Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); preferenceHelper.setMinimumDistanceInMeters(distanceBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); LOG.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); preferenceHelper.setShouldKeepGPSOnBetweenFixes(keepBetweenFix); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); LOG.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime)); preferenceHelper.setLoggingRetryPeriod(retryTime); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absoluteTimeout = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); LOG.debug("Intent received - Set Retry Time: " + String.valueOf(absoluteTimeout)); preferenceHelper.setAbsoluteTimeoutForAcquiringPosition(absoluteTimeout); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); LOG.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; logOnce(); } try { if (bundle.get(Intent.EXTRA_ALARM_COUNT) != "0") { needToStartGpsManager = true; } } catch (Throwable t) { LOG.warn(SessionLogcatAppender.MARKER_INTERNAL, "Received a weird EXTRA_ALARM_COUNT value. Cannot continue."); needToStartGpsManager = false; } if (needToStartGpsManager && Session.isStarted()) { startGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. LOG.debug("Service restarted with null intent. Were we logging previously - " + Session.isStarted()); if (Session.isStarted()) { startLogging(); } } }
From source file:com.crearo.gpslogger.GpsLoggingService.java
private void handleIntent(Intent intent) { ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return;//from ww w . ja v a 2s. c om } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { LOG.info("Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { LOG.info("Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { LOG.info("Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); } if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { LOG.info("Intent received - Get Next Point"); needToStartGpsManager = true; } if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { LOG.info("Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault() .post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); } if (bundle.getString(IntentConstants.SWITCH_PROFILE) != null) { LOG.info("Intent received - switch profile: " + bundle.getString(IntentConstants.SWITCH_PROFILE)); EventBus.getDefault().post( new ProfileEvents.SwitchToProfile(bundle.getString(IntentConstants.SWITCH_PROFILE))); } if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); LOG.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); if (preferCellTower) { preferenceHelper.setChosenListeners(0); } else { preferenceHelper.setChosenListeners(1, 2); } needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); LOG.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); preferenceHelper.setMinimumLoggingInterval(timeBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); LOG.debug("Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); preferenceHelper.setMinimumDistanceInMeters(distanceBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); LOG.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); preferenceHelper.setShouldKeepGPSOnBetweenFixes(keepBetweenFix); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); LOG.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime)); preferenceHelper.setLoggingRetryPeriod(retryTime); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absoluteTimeout = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); LOG.debug("Intent received - Set Retry Time: " + String.valueOf(absoluteTimeout)); preferenceHelper.setAbsoluteTimeoutForAcquiringPosition(absoluteTimeout); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); LOG.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; logOnce(); } try { if (bundle.get(Intent.EXTRA_ALARM_COUNT) != "0") { needToStartGpsManager = true; } } catch (Throwable t) { LOG.warn(SessionLogcatAppender.MARKER_INTERNAL, "Received a weird EXTRA_ALARM_COUNT value. Cannot continue."); needToStartGpsManager = false; } if (needToStartGpsManager && Session.isStarted()) { startGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. LOG.debug("Service restarted with null intent. Start logging."); startLogging(); } }
From source file:com.mjhram.geodata.GpsLoggingService.java
private void HandleIntent(Intent intent) { ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return;//from w w w . j a va2 s .co m } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; //availabilityState = bundle.getInt("availabilityState"); /*if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { tracer.info("Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { tracer.info("Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { tracer.info("Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); }*/ if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { tracer.info("Intent received - Get Next Point"); needToStartGpsManager = true; } /*if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { tracer.info("Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault().post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); }*/ if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); tracer.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); if (preferCellTower) { AppSettings.setChosenListeners(0); } else { AppSettings.setChosenListeners(1, 2); } needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); tracer.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); AppSettings.setMinimumLoggingInterval(timeBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); tracer.debug("Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); AppSettings.setMinimumDistanceInMeters(distanceBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); tracer.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); AppSettings.setShouldKeepGPSOnBetweenFixes(keepBetweenFix); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); tracer.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime)); AppSettings.setLoggingRetryPeriod(retryTime); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absoluteTimeout = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); tracer.debug("Intent received - Set Retry Time: " + String.valueOf(absoluteTimeout)); AppSettings.setAbsoluteTimeoutForAcquiringPosition(absoluteTimeout); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); tracer.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; LogOnce(); } try { if (bundle.get(Intent.EXTRA_ALARM_COUNT) != "0") { needToStartGpsManager = true; } } catch (Throwable t) { tracer.warn(SessionLogcatAppender.MARKER_INTERNAL, "Received a weird EXTRA_ALARM_COUNT value. Cannot continue."); needToStartGpsManager = false; } if (needToStartGpsManager && Session.isStarted()) { StartGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. tracer.debug("Service restarted with null intent. Start logging."); StartLogging(); } }
From source file:com.raddapp.radika.raddappv001.GpsLoggingService.java
private void HandleIntent(Intent intent) { Log.d("GPSLOGSERV 101", "HandleIntent"); ActivityRecognitionResult arr = ActivityRecognitionResult.extractResult(intent); if (arr != null) { EventBus.getDefault().post(new ServiceEvents.ActivityRecognitionEvent(arr)); return;// w w w . java2s . c om } if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { boolean needToStartGpsManager = false; if (bundle.getBoolean(IntentConstants.IMMEDIATE_START)) { //tracer.info("Intent received - Start Logging Now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); } if (bundle.getBoolean(IntentConstants.IMMEDIATE_STOP)) { //tracer.info("Intent received - Stop logging now"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(false)); } if (bundle.getBoolean(IntentConstants.AUTOSEND_NOW)) { //tracer.info("Intent received - Send Email Now"); EventBus.getDefault().postSticky(new CommandEvents.AutoSend(null)); } if (bundle.getBoolean(IntentConstants.GET_NEXT_POINT)) { //tracer.info("Intent received - Get Next Point"); needToStartGpsManager = true; } if (bundle.getString(IntentConstants.SET_DESCRIPTION) != null) { //tracer.info("Intent received - Set Next Point Description: " + bundle.getString(IntentConstants.SET_DESCRIPTION)); EventBus.getDefault() .post(new CommandEvents.Annotate(bundle.getString(IntentConstants.SET_DESCRIPTION))); } if (bundle.get(IntentConstants.PREFER_CELLTOWER) != null) { boolean preferCellTower = bundle.getBoolean(IntentConstants.PREFER_CELLTOWER); //tracer.debug("Intent received - Set Prefer Cell Tower: " + String.valueOf(preferCellTower)); if (preferCellTower) { // AppSettings.setChosenListeners(0); } else { //AppSettings.setChosenListeners(1,2); } needToStartGpsManager = true; } if (bundle.get(IntentConstants.TIME_BEFORE_LOGGING) != null) { int timeBeforeLogging = bundle.getInt(IntentConstants.TIME_BEFORE_LOGGING); //tracer.debug("Intent received - Set Time Before Logging: " + String.valueOf(timeBeforeLogging)); //AppSettings.setMinimumLoggingInterval(timeBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.DISTANCE_BEFORE_LOGGING) != null) { int distanceBeforeLogging = bundle.getInt(IntentConstants.DISTANCE_BEFORE_LOGGING); //tracer.debug("Intent received - Set Distance Before Logging: " + String.valueOf(distanceBeforeLogging)); //AppSettings.setMinimumDistanceInMeters(distanceBeforeLogging); needToStartGpsManager = true; } if (bundle.get(IntentConstants.GPS_ON_BETWEEN_FIX) != null) { boolean keepBetweenFix = bundle.getBoolean(IntentConstants.GPS_ON_BETWEEN_FIX); //tracer.debug("Intent received - Set Keep Between Fix: " + String.valueOf(keepBetweenFix)); //AppSettings.setShouldKeepGPSOnBetweenFixes(keepBetweenFix); needToStartGpsManager = true; } if (bundle.get(IntentConstants.RETRY_TIME) != null) { int retryTime = bundle.getInt(IntentConstants.RETRY_TIME); //tracer.debug("Intent received - Set Retry Time: " + String.valueOf(retryTime)); //AppSettings.setLoggingRetryPeriod(retryTime); needToStartGpsManager = true; } if (bundle.get(IntentConstants.ABSOLUTE_TIMEOUT) != null) { int absoluteTimeout = bundle.getInt(IntentConstants.ABSOLUTE_TIMEOUT); // tracer.debug("Intent received - Set Retry Time: " + String.valueOf(absoluteTimeout)); //AppSettings.setAbsoluteTimeoutForAcquiringPosition(absoluteTimeout); needToStartGpsManager = true; } if (bundle.get(IntentConstants.LOG_ONCE) != null) { boolean logOnceIntent = bundle.getBoolean(IntentConstants.LOG_ONCE); //tracer.debug("Intent received - Log Once: " + String.valueOf(logOnceIntent)); needToStartGpsManager = false; LogOnce(); } try { if (bundle.get(Intent.EXTRA_ALARM_COUNT) != "0") { needToStartGpsManager = true; } } catch (Throwable t) { //tracer.warn(SessionLogcatAppender.MARKER_INTERNAL, "Received a weird EXTRA_ALARM_COUNT value. Cannot continue."); needToStartGpsManager = false; } if (needToStartGpsManager && Session.isStarted()) { // StartGpsManager(); } } } else { // A null intent is passed in if the service has been killed and restarted. //tracer.debug("Service restarted with null intent. Start logging."); StartLogging(); } //StartLogging(); }
From source file:biz.wiz.android.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("service start command: " + intent + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT) ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")" : "")); final String action = intent.getAction(); if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationCount = 0;// w ww. ja v a 2s.c o m notificationAccumulatedAmount = Coin.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = new Sha256Hash( intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:org.hopestarter.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("service start command: " + intent + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT) ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")" : "")); final String action = intent.getAction(); if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationCount = 0;//from w w w. j a v a 2s . c o m notificationAccumulatedAmount = Coin.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = Sha256Hash .wrap(intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:com.tribesman.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("service start command: " + intent + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT) ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")" : "")); final String action = intent.getAction(); if (ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationCount = 0;/*from w w w. j a v a 2s . c om*/ notificationAccumulatedAmount = BigInteger.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = new Sha256Hash(intent.getByteArrayExtra(ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }