List of usage examples for android.app Service getString
@NonNull public final String getString(@StringRes int resId)
From source file:org.broeuschmeul.android.gps.usb.provider.driver.USBGpsManager.java
/** * @param callingService/* w w w. ja v a 2 s .c o m*/ * @param vendorId * @param productId * @param maxRetries */ public USBGpsManager(Service callingService, int vendorId, int productId, int maxRetries) { this.gpsVendorId = vendorId; this.gpsProductId = productId; this.callingService = callingService; this.maxConnectionRetries = maxRetries + 1; this.nbRetriesRemaining = maxConnectionRetries; this.appContext = callingService.getApplicationContext(); this.parser = new NmeaParser(10f, this.appContext); locationManager = (LocationManager) callingService.getSystemService(Context.LOCATION_SERVICE); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(callingService); deviceSpeed = sharedPreferences.getString(USBGpsProviderService.PREF_GPS_DEVICE_SPEED, callingService.getString(R.string.defaultGpsDeviceSpeed)); shouldSetTime = sharedPreferences.getBoolean(USBGpsProviderService.PREF_SET_TIME, false); timeSetAlready = true; defaultDeviceSpeed = callingService.getString(R.string.defaultGpsDeviceSpeed); setDeviceSpeed = !deviceSpeed.equals(callingService.getString(R.string.autoGpsDeviceSpeed)); sirfGps = sharedPreferences.getBoolean(USBGpsProviderService.PREF_SIRF_GPS, false); notificationManager = (NotificationManager) callingService.getSystemService(Context.NOTIFICATION_SERVICE); parser.setLocationManager(locationManager); Intent stopIntent = new Intent(USBGpsProviderService.ACTION_STOP_GPS_PROVIDER); PendingIntent stopPendingIntent = PendingIntent.getService(appContext, 0, stopIntent, PendingIntent.FLAG_CANCEL_CURRENT); connectionProblemNotificationBuilder = new NotificationCompat.Builder(appContext) .setContentIntent(stopPendingIntent).setSmallIcon(R.drawable.ic_stat_notify); Intent restartIntent = new Intent(USBGpsProviderService.ACTION_START_GPS_PROVIDER); PendingIntent restartPendingIntent = PendingIntent.getService(appContext, 0, restartIntent, PendingIntent.FLAG_CANCEL_CURRENT); serviceStoppedNotificationBuilder = new NotificationCompat.Builder(appContext) .setContentIntent(restartPendingIntent).setSmallIcon(R.drawable.ic_stat_notify) .setContentTitle( appContext.getString(R.string.service_closed_because_connection_problem_notification_title)) .setContentText( appContext.getString(R.string.service_closed_because_connection_problem_notification)); usbManager = (UsbManager) callingService.getSystemService(Service.USB_SERVICE); }