sendLaunchRequest method

Future<void> sendLaunchRequest({
  1. AppControlReplyCallback? replyCallback,
})

Sends a launch request to an application.

The http://tizen.org/privilege/appmanager.launch privilege is required to use this API.

If replyCallback is null, this call returns immediately after sending a request to the platform.

If replyCallback is non-null, this call will not return until a reply is received from the callee and replyCallback is invoked. If the callee doesn't reply to the request or is terminated before replying, this call will never return and replyCallback will never be invoked, resulting in a memory leak.

Implementation

Future<void> sendLaunchRequest({
  AppControlReplyCallback? replyCallback,
}) async {
  await _setAppControlData();

  final Map<String, dynamic> args = <String, dynamic>{
    'id': _id,
    'waitForReply': replyCallback != null,
  };
  if (replyCallback == null) {
    await _methodChannel.invokeMethod<void>('sendLaunchRequest', args);
  } else {
    final dynamic response =
        await _methodChannel.invokeMethod<dynamic>('sendLaunchRequest', args);
    final Map<String, dynamic> responseMap =
        (response as Map<dynamic, dynamic>).cast<String, dynamic>();
    final AppControlReplyResult result =
        AppControlReplyResult.values.byName(responseMap['result'] as String);
    final Map<String, dynamic> replyMap =
        (responseMap['reply'] as Map<dynamic, dynamic>)
            .cast<String, dynamic>();
    final AppControl reply = AppControl._fromMap(replyMap);
    await replyCallback(this, reply, result);
  }
}