Skip to content

Commit

Permalink
External activity failure - ignore resolveActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
martinwork committed Sep 17, 2024
1 parent 590a415 commit 8d9c464
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions app/src/main/java/com/samsung/microbit/ui/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,25 +336,29 @@ public static int safelyStartActivity( Context context, boolean report, Intent i
int error = 0;
ComponentName componentName = intent.resolveActivity( context.getPackageManager());
if ( componentName == null) {
/* TODO: Why is componentName null for
ACTION_CREATE_DOCUMENT (unless createChooser is used)
ACTION_VIEW?
*/
Log.i(TAG,"startActivity - no component");
error = 1;
} else {
try {
if ( forResult) {
if ( !(context instanceof Activity)) {
error = 3;
} else {
((Activity) context).startActivityForResult(intent, requestCode, options);
}
}

try {
if ( forResult) {
if ( !(context instanceof Activity)) {
error = 3;
} else {
context.startActivity(intent);
((Activity) context).startActivityForResult(intent, requestCode, options);
}
} catch (Exception e) {
Log.i(TAG, "startActivity - exception");
e.printStackTrace();
error = 2;
} else {
context.startActivity(intent);
}
} catch (Exception e) {
Log.i(TAG, "startActivity - exception");
e.printStackTrace();
error = 2;
}

if ( report && error != 0) {
safelyStartActivityToastGeneric( context);
}
Expand Down

0 comments on commit 8d9c464

Please sign in to comment.