Skip to content

Commit b09080e

Browse files
committed
Fix backToForeground method.
1 parent 0933f2b commit b09080e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

android/src/main/java/io/wazo/callkeep/CallKeepModule.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public static Boolean isConnectionServiceAvailable() {
544544
@SuppressLint("WrongConstant")
545545
public void backToForeground(@NonNull MethodChannel.Result result) {
546546
Context context = getAppContext();
547-
String packageName = context.getApplicationContext().getPackageName();
547+
String packageName = context.getPackageName();
548548
Intent focusIntent = context.getPackageManager().getLaunchIntentForPackage(packageName).cloneFilter();
549549
Activity activity = this._currentActivity;
550550
boolean isOpened = activity != null;
@@ -557,10 +557,13 @@ public void backToForeground(@NonNull MethodChannel.Result result) {
557557
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
558558
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
559559
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
560-
561-
this._currentActivity.startActivity(focusIntent);
560+
if (activity != null) {
561+
activity.startActivity(focusIntent);
562+
} else {
563+
context.startActivity(focusIntent);
564+
}
562565
}
563-
result.success(null);
566+
result.success(isOpened);
564567
}
565568

566569
private void initializeTelecomManager() {

lib/src/api.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,11 @@ class FlutterCallkeep extends EventManager {
253253

254254
Future<void> backToForeground() async {
255255
if (isIOS) {
256-
return;
256+
return false;
257257
}
258258

259-
await _channel.invokeMethod<void>('backToForeground', <String, dynamic>{});
259+
return await _channel
260+
.invokeMethod<bool>('backToForeground', <String, dynamic>{});
260261
}
261262

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

0 commit comments

Comments
 (0)