Skip to content

Commit

Permalink
Check shortcut action for null
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Apr 23, 2017
1 parent d632c7c commit 96a75f0
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/src/main/java/org/traccar/client/ShortcutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,24 @@ private void checkShortcutAction(Intent intent) {
} else {
action = intent.getStringExtra(EXTRA_ACTION);
}
switch (action) {
case EXTRA_ACTION_START:
PreferenceManager.getDefaultSharedPreferences(this)
.edit().putBoolean(MainActivity.KEY_STATUS, true).commit();
startService(new Intent(this, TrackingService.class));
Toast.makeText(this, R.string.status_service_create, Toast.LENGTH_SHORT).show();
break;
case EXTRA_ACTION_STOP:
PreferenceManager.getDefaultSharedPreferences(this)
.edit().putBoolean(MainActivity.KEY_STATUS, false).commit();
stopService(new Intent(this, TrackingService.class));
Toast.makeText(this, R.string.status_service_destroy, Toast.LENGTH_SHORT).show();
break;
case EXTRA_ACTION_SOS:
sendAlarm();
break;
if (action != null) {
switch (action) {
case EXTRA_ACTION_START:
PreferenceManager.getDefaultSharedPreferences(this)
.edit().putBoolean(MainActivity.KEY_STATUS, true).commit();
startService(new Intent(this, TrackingService.class));
Toast.makeText(this, R.string.status_service_create, Toast.LENGTH_SHORT).show();
break;
case EXTRA_ACTION_STOP:
PreferenceManager.getDefaultSharedPreferences(this)
.edit().putBoolean(MainActivity.KEY_STATUS, false).commit();
stopService(new Intent(this, TrackingService.class));
Toast.makeText(this, R.string.status_service_destroy, Toast.LENGTH_SHORT).show();
break;
case EXTRA_ACTION_SOS:
sendAlarm();
break;
}
}
finish();
}
Expand Down

0 comments on commit 96a75f0

Please sign in to comment.