diff options
author | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-09-29 21:42:22 +0100 |
---|---|---|
committer | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-09-30 01:27:10 +0200 |
commit | dbfe6915416d12129fbaa786f5a4955364ef1561 (patch) | |
tree | aee240407e2623dddef628cabd9c48d476ad02f5 /src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java | |
parent | 615c3564f2158c6334d7eddd85f536e95b61091b (diff) | |
download | BlueGPS-dbfe6915416d12129fbaa786f5a4955364ef1561.zip BlueGPS-dbfe6915416d12129fbaa786f5a4955364ef1561.tar.gz BlueGPS-dbfe6915416d12129fbaa786f5a4955364ef1561.tar.bz2 |
add preference settings for connection retries
Diffstat (limited to 'src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java')
-rw-r--r-- | src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java index fc97751..58b4ede 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java @@ -157,10 +157,12 @@ public class BlueetoothGpsManager { private Notification serviceStoppedNotification;
private Context appContext;
private NotificationManager notificationManager;
-
- public BlueetoothGpsManager(Service callingService, String deviceAddress) {
+ private int maxConnectionRetries;
+
+ public BlueetoothGpsManager(Service callingService, String deviceAddress, int maxRetries) {
this.gpsDeviceAddress = deviceAddress;
this.callingService = callingService;
+ this.maxConnectionRetries = maxRetries;
this.appContext = callingService.getApplicationContext();
locationManager = (LocationManager)callingService.getSystemService(Context.LOCATION_SERVICE);
notificationManager = (NotificationManager)callingService.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -177,7 +179,10 @@ public class BlueetoothGpsManager { serviceStoppedNotification.icon=R.drawable.icon;
Intent restartIntent = new Intent(BluetoothGpsProviderService.ACTION_START_GPS_PROVIDER);
PendingIntent restartPendingIntent = PendingIntent.getService(appContext, 0, restartIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- serviceStoppedNotification.setLatestEventInfo(appContext, appContext.getString(R.string.service_closed_because_connection_problem_notification_title), appContext.getString(R.string.service_closed_because_connection_problem_notification_title), restartPendingIntent);
+ serviceStoppedNotification.setLatestEventInfo(appContext,
+ appContext.getString(R.string.service_closed_because_connection_problem_notification_title),
+ appContext.getString(R.string.service_closed_because_connection_problem_notification),
+ restartPendingIntent);
}
@@ -268,7 +273,7 @@ public class BlueetoothGpsManager { }
// if bluetooth has bean disabled or
// if two much tries consider that we are enable to connect. So close everything and get out
- if ((!bluetoothAdapter.isEnabled()) || (connectionTry >= 5 )){
+ if ((!bluetoothAdapter.isEnabled()) || (connectionTry >= maxConnectionRetries )){
notificationManager.cancel(R.string.connection_problem_notification_title);
serviceStoppedNotification.when = System.currentTimeMillis();
notificationManager.notify(R.string.service_closed_because_connection_problem_notification_title, serviceStoppedNotification);
|