Skip to content

Commit

Permalink
Merge pull request #367 from puzzlsoftwarehouse/feat/open_app
Browse files Browse the repository at this point in the history
add function of open app
  • Loading branch information
ekasetiawans committed Oct 24, 2023
2 parents 0cfc44d + ab67983 commit 0c486ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
}
return;
}

if(method.equalsIgnoreCase("openApp")){
try{
String packageName= getPackageName();
Intent launchIntent= getPackageManager().getLaunchIntentForPackage(packageName);
if (launchIntent != null) {
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

startActivity(launchIntent);
result.success(true);

}
}catch (Exception e){
result.error("open app failure", e.getMessage(),e);

}
return;

}
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,9 @@ class AndroidServiceInstance extends ServiceInstance {
"value": value,
});
}

Future<bool> openApp() async {
final result = await _channel.invokeMethod('openApp');
return result ?? false;
}
}

0 comments on commit 0c486ab

Please sign in to comment.