|
32 | 32 | import android.net.Uri;
|
33 | 33 | import android.os.Build;
|
34 | 34 | import android.os.Bundle;
|
| 35 | +import android.view.WindowManager; |
35 | 36 | import android.support.annotation.NonNull;
|
36 | 37 | import android.support.annotation.Nullable;
|
37 | 38 | import android.support.v4.app.ActivityCompat;
|
@@ -420,11 +421,22 @@ public void backToForeground() {
|
420 | 421 | Context context = getAppContext();
|
421 | 422 | String packageName = context.getApplicationContext().getPackageName();
|
422 | 423 | Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter();
|
| 424 | + Activity activity = getCurrentActivity(); |
| 425 | + boolean isOpened = activity != null; |
| 426 | + Log.d(TAG, "backToForeground, app isOpened ?" + (isOpened ? "true" : "false")); |
423 | 427 |
|
424 |
| - focusIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |
| 428 | + if (isOpened) { |
| 429 | + focusIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |
| 430 | + activity.startActivity(focusIntent); |
| 431 | + } else { |
425 | 432 |
|
426 |
| - Activity activity = getCurrentActivity(); |
427 |
| - activity.startActivity(focusIntent); |
| 433 | + focusIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + |
| 434 | + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + |
| 435 | + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + |
| 436 | + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); |
| 437 | + |
| 438 | + getReactApplicationContext().startActivity(focusIntent); |
| 439 | + } |
428 | 440 | }
|
429 | 441 |
|
430 | 442 | private void registerPhoneAccount(Context appContext) {
|
|
0 commit comments