Skip to content

Commit 14c340f

Browse files
committed
Clean up of startOrResumeApp
* No behavior changes in this commit, just clean up * inContext -> activity - As we are requiring an Activity, not just any Context * Early retrun for launchIntent null check. * Better comment of why launchIntent has a null check
1 parent b27ac14 commit 14c340f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,16 +2169,16 @@ static void applicationOpenedByNotification(@Nullable final String notificationI
21692169
sessionManager.onDirectInfluenceFromNotificationOpen(appEntryState, notificationId);
21702170
}
21712171

2172-
static boolean startOrResumeApp(Activity inContext) {
2173-
Intent launchIntent = inContext.getPackageManager().getLaunchIntentForPackage(inContext.getPackageName());
2174-
logger.debug("startOrResumeApp from context: " + inContext + " isRoot: " + inContext.isTaskRoot() + " with launchIntent: " + launchIntent);
2175-
// Make sure we have a launcher intent.
2176-
if (launchIntent != null) {
2177-
inContext.startActivity(launchIntent);
2178-
return true;
2179-
}
2172+
static boolean startOrResumeApp(Activity activity) {
2173+
Intent launchIntent = activity.getPackageManager().getLaunchIntentForPackage(activity.getPackageName());
2174+
logger.debug("startOrResumeApp from context: " + activity + " isRoot: " + activity.isTaskRoot() + " with launchIntent: " + launchIntent);
21802175

2181-
return false;
2176+
// Not all apps have a launcher intent, such as one that only provides a homescreen widget
2177+
if (launchIntent == null)
2178+
return false;
2179+
2180+
activity.startActivity(launchIntent);
2181+
return true;
21822182
}
21832183

21842184
/**

0 commit comments

Comments
 (0)