本文整理汇总了Java中com.connectsdk.service.sessions.LaunchSession.getService方法的典型用法代码示例。如果您正苦于以下问题:Java LaunchSession.getService方法的具体用法?Java LaunchSession.getService怎么用?Java LaunchSession.getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.connectsdk.service.sessions.LaunchSession
的用法示例。
在下文中一共展示了LaunchSession.getService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例3: closeLaunchSession
import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
/**
* Closes the session on the first screen device. Depending on the sessionType, the associated service will have different ways of handling the close functionality.
*
* @param launchSession LaunchSession to close
* @param listener (optional) listener to be called on success/failure
*/
public void closeLaunchSession(LaunchSession launchSession, ResponseListener<Object> listener) {
if (launchSession == null) {
Util.postError(listener, new ServiceCommandError(0, "You must provide a valid LaunchSession", null));
return;
}
DeviceService service = launchSession.getService();
if (service == null) {
Util.postError(listener, new ServiceCommandError(0, "There is no service attached to this launch session", null));
return;
}
switch (launchSession.getSessionType()) {
case App:
if (service instanceof Launcher)
((Launcher) service).closeApp(launchSession, listener);
break;
case Media:
if (service instanceof MediaPlayer)
((MediaPlayer) service).closeMedia(launchSession, listener);
break;
case ExternalInputPicker:
if (service instanceof ExternalInputControl)
((ExternalInputControl) service).closeInputPicker(launchSession, listener);
break;
case WebApp:
if (service instanceof WebAppLauncher)
((WebAppLauncher) service).closeWebApp(launchSession, listener);
break;
case Unknown:
default:
Util.postError(listener, new ServiceCommandError(0, "This DeviceService does not know ho to close this LaunchSession", null));
break;
}
}
示例4: closeApp
import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeApp(LaunchSession launchSession, ResponseListener<Object> listener) {
String requestURL = getUDAPRequestURL(UDAP_PATH_APPTOAPP_COMMAND);
Map <String,String> params = new HashMap<String,String>();
params.put("name", "AppTerminate");
params.put("auid", launchSession.getAppId());
if (launchSession.getAppName() != null)
params.put("appname", HttpMessage.encode(launchSession.getAppName()));
String httpMessage = getUDAPMessageBody(UDAP_API_COMMAND, params);
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(launchSession.getService(), requestURL, httpMessage, listener);
command.send();
}
示例5: closeMedia
import com.connectsdk.service.sessions.LaunchSession; //导入方法依赖的package包/类
@Override
public void closeMedia(LaunchSession launchSession, ResponseListener<Object> listener) {
if (launchSession.getService() instanceof DLNAService)
((DLNAService) launchSession.getService()).stop(listener);
}