catch ActivityNotFoundException when requesting battery op
This commit is contained in:
parent
c7882b7225
commit
d5608cb4f3
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue