Skip to content

Commit

Permalink
Catch ActivityNotFound exception to prevent crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ozdemir08 committed Nov 6, 2019
1 parent 873b57b commit c7d4eda
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_SELECT_OPPONENTS_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_SELECT_OPPONENTS_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_CAPTURE_OVERLAY_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_CAPTURE_OVERLAY_UI);
helperFragment.finishRequest(CaptureOverlayUiRequest.this);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_INBOX_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_INBOX_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_SELECT_SNAPSHOT_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_SELECT_SNAPSHOT_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_SHOW_INVITATION_INBOX_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_SHOW_INVITATION_INBOX_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_SHOW_WAITING_ROOM_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_SHOW_WAITING_ROOM_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void process(final HelperFragment helperFragment) {
new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
helperFragment.startActivityForResult(intent, HelperFragment.RC_SIMPLE_UI);
Utils.startActivityForResult(helperFragment, intent, HelperFragment.RC_SIMPLE_UI);
}
})
.addOnFailureListener(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.google.games.bridge;

import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.util.Log;

/**
* Utility functions
*/
public final class Utils {

private static final String TAG = "Utils";

private Utils() {}

public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
try {
fragment.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException e) {
Log.e(TAG,"Activity not found. Please install Play Games App.");
}
}
}

0 comments on commit c7d4eda

Please sign in to comment.