当前位置: 首页>>代码示例>>Java>>正文


Java LaunchSession.getAppId方法代码示例

本文整理汇总了Java中com.connectsdk.service.sessions.LaunchSession.getAppId方法的典型用法代码示例。如果您正苦于以下问题:Java LaunchSession.getAppId方法的具体用法?Java LaunchSession.getAppId怎么用?Java LaunchSession.getAppId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.connectsdk.service.sessions.LaunchSession的用法示例。


在下文中一共展示了LaunchSession.getAppId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: closeApp

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeApp(LaunchSession launchSession, ResponseListener<Object> listener) {
    String uri = "ssap://system.launcher/close";
    String appId = launchSession.getAppId();
    String sessionId = launchSession.getSessionId();

    JSONObject payload = new JSONObject();

    try {
        payload.put("id", appId);
        payload.put("sessionId", sessionId);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(launchSession.getService(), uri, payload, true, listener);
    request.send();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:19,代码来源:WebOSTVService.java

示例2: closeMedia

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeMedia(LaunchSession launchSession, ResponseListener<Object> listener) {
    JSONObject payload = new JSONObject();

    try {
        if (launchSession.getAppId() != null && launchSession.getAppId().length() > 0)
            payload.put("id", launchSession.getAppId());

        if (launchSession.getSessionId() != null && launchSession.getSessionId().length() > 0)
            payload.put("sessionId", launchSession.getSessionId());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(launchSession.getService(), CLOSE_MEDIA_URI, payload, true, listener);
    request.send();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:WebOSTVService.java

示例3: closeWebApp

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeWebApp(LaunchSession launchSession, final ResponseListener<Object> listener) {
    if (launchSession == null || launchSession.getAppId() == null || launchSession.getAppId().length() == 0) {
        Util.postError(listener, new ServiceCommandError(0, "Must provide a valid launch session", null));
        return;
    }

    final WebOSWebAppSession webAppSession = mWebAppSessions.get(launchSession.getAppId());
    if (webAppSession != null) {
        webAppSession.disconnectFromWebApp();
    }

    String uri = "ssap://webapp/closeWebApp";
    JSONObject payload = new JSONObject();

    try {
        if (launchSession.getAppId() != null) payload.put("webAppId", launchSession.getAppId());
        if (launchSession.getSessionId() != null) payload.put("sessionId", launchSession.getSessionId());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, listener);
    request.send();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:26,代码来源:WebOSTVService.java

示例4: sendMessage

import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void sendMessage(Object message, LaunchSession launchSession, ResponseListener<Object> listener) {
    if (launchSession == null || launchSession.getAppId() == null) {
        Util.postError(listener, new ServiceCommandError(0, "Must provide a valid LaunchSession object", null));
        return;
    }

    if (message == null) {
        Util.postError(listener, new ServiceCommandError(0, "Cannot send a null message", null));
        return;
    }

    if (socket == null) {
        connect();
    }

    String appId = launchSession.getAppId();
    String fullAppId = appId;

    if (launchSession.getSessionType() == LaunchSessionType.WebApp)
        fullAppId = mAppToAppIdMappings.get(appId);

    if (fullAppId == null || fullAppId.length() == 0) {
        Util.postError(listener, new ServiceCommandError(-1, "You must provide a valid LaunchSession to send messages to", null));

        return;
    }

    JSONObject payload = new JSONObject();

    try {
        payload.put("type", "p2p");
        payload.put("to", fullAppId);
        payload.put("payload", message);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, null, payload, true, listener);
    sendCommand(request);
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:42,代码来源:WebOSTVService.java


注:本文中的com.connectsdk.service.sessions.LaunchSession.getAppId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。