Skip to content

Commit

Permalink
Fix backToForeground method.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Jan 7, 2021
1 parent 0933f2b commit b09080e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions android/src/main/java/io/wazo/callkeep/CallKeepModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public static Boolean isConnectionServiceAvailable() {
@SuppressLint("WrongConstant")
public void backToForeground(@NonNull MethodChannel.Result result) {
Context context = getAppContext();
String packageName = context.getApplicationContext().getPackageName();
String packageName = context.getPackageName();
Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter();
Activity activity = this._currentActivity;
boolean isOpened = activity != null;
Expand All @@ -557,10 +557,13 @@ public void backToForeground(@NonNull MethodChannel.Result result) {
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

this._currentActivity.startActivity(focusIntent);
if (activity != null) {
activity.startActivity(focusIntent);
} else {
context.startActivity(focusIntent);
}
}
result.success(null);
result.success(isOpened);
}

private void initializeTelecomManager() {
Expand Down
5 changes: 3 additions & 2 deletions lib/src/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,11 @@ class FlutterCallkeep extends EventManager {

Future<void> backToForeground() async {
if (isIOS) {
return;
return false;
}

await _channel.invokeMethod<void>('backToForeground', <String, dynamic>{});
return await _channel
.invokeMethod<bool>('backToForeground', <String, dynamic>{});
}

Future<void> _setupIOS(Map<String, dynamic> options) async {
Expand Down

0 comments on commit b09080e

Please sign in to comment.