Handle runtime exceptions
Этот коммит содержится в:
@@ -29,6 +29,7 @@ import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PositionProvider implements LocationListener {
|
||||
|
||||
@@ -69,10 +70,14 @@ public class PositionProvider implements LocationListener {
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
public void startUpdates() {
|
||||
try {
|
||||
locationManager.requestLocationUpdates(
|
||||
distance > 0 || angle > 0 ? MINIMUM_INTERVAL : interval, 0,
|
||||
getCriteria(preferences.getString(MainFragment.KEY_ACCURACY, "medium")),
|
||||
this, Looper.myLooper());
|
||||
} catch (RuntimeException e) {
|
||||
Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static Criteria getCriteria(String accuracy) {
|
||||
|
||||
@@ -111,6 +111,7 @@ public class ShortcutActivity extends AppCompatActivity {
|
||||
Criteria criteria = PositionProvider.getCriteria(
|
||||
preferences.getString(MainFragment.KEY_ACCURACY, "medium"));
|
||||
|
||||
try {
|
||||
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, true));
|
||||
if (location != null) {
|
||||
sendAlarmLocation(location);
|
||||
@@ -134,6 +135,9 @@ public class ShortcutActivity extends AppCompatActivity {
|
||||
}
|
||||
}, Looper.myLooper());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAlarmLocation(Location location) {
|
||||
|
||||
Ссылка в новой задаче
Block a user