Prevent crash on activity not found

android.provider.MediaStore.RECORD_SOUND was reported to be available while it was not
This commit is contained in:
M66B
2019-08-17 10:26:36 +02:00
parent 505fdc241a
commit a838cc9d84
2 changed files with 36 additions and 12 deletions

View File

@@ -20,12 +20,14 @@ package eu.faircode.email;
*/
import android.Manifest;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.PowerManager;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
@@ -186,16 +188,26 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override
public void startActivity(Intent intent) {
if (Helper.hasAuthentication(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivity(intent);
try {
if (Helper.hasAuthentication(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e(ex);
ToastEx.makeText(this, getString(R.string.title_no_viewer, intent.getAction()), Toast.LENGTH_LONG).show();
}
}
@Override
public void startActivityForResult(Intent intent, int requestCode) {
if (Helper.hasAuthentication(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivityForResult(intent, requestCode);
try {
if (Helper.hasAuthentication(this))
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
super.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException ex) {
Log.e(ex);
ToastEx.makeText(this, getString(R.string.title_no_viewer, intent.getAction()), Toast.LENGTH_LONG).show();
}
}
@Override