Skip to content

Commit

Permalink
Android/Native: fixing crash when subclassing CoronaActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Shchvova committed Feb 3, 2021
1 parent fcf6c46 commit 02d0172
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,23 @@ public void onReceive(android.content.Context context, android.content.Intent in
}

// Display the Corona activity window if not already visible.
intent = new android.content.Intent(context, com.ansca.corona.CoronaActivity.class);
Class<?> activityClass = com.ansca.corona.CoronaActivity.class;
try {
android.content.pm.PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), android.content.pm.PackageManager.GET_ACTIVITIES);
for (android.content.pm.ActivityInfo ai : pi.activities) {
try {
Class<?> c = Class.forName(ai.name);
if (com.ansca.corona.CoronaActivity.class.isAssignableFrom(c)) {
activityClass = c;
break;
}
} catch (Throwable ignore) {
}
}
}
catch (Throwable ignore) {
}
intent = new android.content.Intent(context, activityClass);
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra(com.ansca.corona.events.NotificationReceivedTask.NAME, event.toBundle());
Expand Down

0 comments on commit 02d0172

Please sign in to comment.