diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 7 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java | 7 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index dbd3139fd..2c98e4e7c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -5,6 +5,7 @@ import android.app.ActionBar; import android.app.AlertDialog; import android.app.FragmentTransaction; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -1392,7 +1393,11 @@ public class ConversationActivity extends XmppActivity Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); Uri uri = Uri.parse("package:" + getPackageName()); intent.setData(uri); - startActivityForResult(intent, REQUEST_BATTERY_OP); + try { + startActivityForResult(intent, REQUEST_BATTERY_OP); + } catch (ActivityNotFoundException e) { + Toast.makeText(ConversationActivity.this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show(); + } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 3d7eb1ccc..59ac7e1bb 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -3,6 +3,7 @@ package eu.siacs.conversations.ui; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -445,7 +446,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); Uri uri = Uri.parse("package:"+getPackageName()); intent.setData(uri); - startActivityForResult(intent,REQUEST_BATTERY_OP); + try { + startActivityForResult(intent, REQUEST_BATTERY_OP); + } catch (ActivityNotFoundException e) { + Toast.makeText(EditAccountActivity.this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show(); + } } }); this.mSessionEst = (TextView) findViewById(R.id.session_est); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7c027b509..ae5c704c1 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -635,4 +635,5 @@ <string name="presence_xa">Not Available</string> <string name="presence_dnd">Busy</string> <string name="secure_password_generated">A secure password has been generated</string> + <string name="device_does_not_support_battery_op">Your device does not support opting out of battery optimization</string> </resources> |