本文整理汇总了Java中com.connectsdk.service.sessions.LaunchSession类的典型用法代码示例。如果您正苦于以下问题:Java LaunchSession类的具体用法?Java LaunchSession怎么用?Java LaunchSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LaunchSession类属于com.connectsdk.service.sessions包,在下文中一共展示了LaunchSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchAppWithInfo
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void launchAppWithInfo(final AppInfo appInfo, Object params, final AppLaunchListener listener) {
ServiceCommand<ResponseListener<Object>> command =
new ServiceCommand<ResponseListener<Object>>(getCommandProcessor(),
requestURL(appInfo.getName()), params, new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, new ServiceCommandError(0, "Problem Launching app", null));
}
@Override
public void onSuccess(Object object) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appInfo.getId());
launchSession.setAppName(appInfo.getName());
launchSession.setSessionId((String)object);
launchSession.setService(DIALService.this);
launchSession.setSessionType(LaunchSessionType.App);
Util.postSuccess(listener, launchSession);
}
});
command.send();
}
示例2: launchInputPicker
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void launchInputPicker(final AppLaunchListener listener) {
final AppInfo appInfo = new AppInfo() {{
setId("com.webos.app.inputpicker");
setName("InputPicker");
}};
launchAppWithInfo(appInfo, null, new AppLaunchListener() {
@Override
public void onSuccess(LaunchSession object) {
listener.onSuccess(object);
}
@Override
public void onError(ServiceCommandError error) {
appInfo.setId("com.webos.app.inputmgr");
launchAppWithInfo(appInfo, null, listener);
}
});
}
示例3: joinWebApp
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void joinWebApp(final LaunchSession webAppLaunchSession, final WebAppSession.LaunchListener listener) {
final WebOSWebAppSession webAppSession = this.webAppSessionForLaunchSession(webAppLaunchSession);
webAppSession.join(new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(Object object) {
Util.postSuccess(listener, webAppSession);
}
});
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: connectToApp
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
public void connectToApp(String appId, final WebAppSession.LaunchListener listener) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
launchSession.setSessionType(LaunchSessionType.App);
launchSession.setService(this);
final WebOSWebAppSession webAppSession = webAppSessionForLaunchSession(launchSession);
connectToWebApp(webAppSession, false, new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(Object object) {
Util.postSuccess(listener, webAppSession);
}
});
}
示例8: testLaunchInputPickerForNewTV
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Test
public void testLaunchInputPickerForNewTV() throws JSONException {
Launcher.AppLaunchListener listener = Mockito.mock(Launcher.AppLaunchListener.class);
service.launchInputPicker(listener);
ArgumentCaptor<ServiceCommand> argCommand = ArgumentCaptor.forClass(ServiceCommand.class);
Mockito.verify(socket).sendCommand(argCommand.capture());
ServiceCommand command = argCommand.getValue();
command.getResponseListener().onError(new ServiceCommandError());
argCommand = ArgumentCaptor.forClass(ServiceCommand.class);
Mockito.verify(socket, Mockito.times(2)).sendCommand(argCommand.capture());
command = argCommand.getValue();
command.getResponseListener().onSuccess(new JSONObject());
Mockito.verify(listener).onSuccess(Mockito.any(LaunchSession.class));
JSONObject payload = (JSONObject)command.getPayload();
Assert.assertEquals("com.webos.app.inputmgr", payload.getString("id"));
}
示例9: closeMedia
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void closeMedia(final LaunchSession launchSession, final ResponseListener<Object> listener) {
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void onConnected() {
try {
Cast.CastApi.stopApplication(mApiClient, launchSession.getSessionId()).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (result.isSuccess()) {
Util.postSuccess(listener, result);
} else {
Util.postError(listener, new ServiceCommandError(result.getStatusCode(), result.getStatusMessage(), result));
}
}
});
} catch (Exception e) {
Util.postError(listener, new ServiceCommandError(0, "Unable to stop", null));
}
}
};
runCommand(connectionListener);
}
示例10: displayMedia
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
private void displayMedia(JSONObject params, final MediaPlayer.LaunchListener listener) {
String uri = "ssap://media.viewer/open";
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object response) {
JSONObject obj = (JSONObject) response;
LaunchSession launchSession = LaunchSession.launchSessionForAppId(obj.optString("id"));
launchSession.setService(WebOSTVService.this);
launchSession.setSessionId(obj.optString("sessionId"));
launchSession.setSessionType(LaunchSessionType.Media);
Util.postSuccess(listener, new MediaLaunchObject(launchSession, WebOSTVService.this));
}
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
};
ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, params, true, responseListener);
request.send();
}
示例11: joinWebApp
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void joinWebApp(String webAppId, WebAppSession.LaunchListener listener) {
LaunchSession launchSession = LaunchSession.launchSessionForAppId(webAppId);
launchSession.setSessionType(LaunchSessionType.WebApp);
launchSession.setService(this);
joinWebApp(launchSession, listener);
}
示例12: closeWebApp
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void closeWebApp(LaunchSession launchSession, final ResponseListener<Object> listener) {
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void onConnected() {
try {
mCastClient.stopApplication(mApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
Util.postSuccess(listener, null);
}
else {
Util.postError(listener, new ServiceCommandError(status.getStatusCode(), status.getStatusMessage(), status));
}
}
});
} catch (Exception e) {
Util.postError(listener, new ServiceCommandError(0, "Unable to stop", null));
}
}
};
runCommand(connectionListener);
}
示例13: onResult
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void onResult(ApplicationConnectionResult result) {
Status status = result.getStatus();
if (status.isSuccess()) {
ApplicationMetadata applicationMetadata = result.getApplicationMetadata();
currentAppId = applicationMetadata.getApplicationId();
LaunchSession launchSession = LaunchSession.launchSessionForAppId(applicationMetadata.getApplicationId());
launchSession.setAppName(applicationMetadata.getName());
launchSession.setSessionId(result.getSessionId());
launchSession.setSessionType(LaunchSessionType.WebApp);
launchSession.setService(CastService.this);
CastWebAppSession webAppSession = new CastWebAppSession(launchSession, CastService.this);
webAppSession.setMetadata(applicationMetadata);
sessions.put(applicationMetadata.getApplicationId(), webAppSession);
if (listener != null) {
listener.onSuccess(webAppSession);
}
launchingAppId = null;
}
else {
if (listener != null) {
listener.onFailure(new ServiceCommandError(status.getStatusCode(), status.getStatusMessage(), status));
}
}
}
示例14: 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;
}
}
示例15: decodeLaunchSession
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public LaunchSession decodeLaunchSession(String type, JSONObject sessionObj) throws JSONException {
if (type.equals("dlna")) {
LaunchSession launchSession = LaunchSession.launchSessionFromJSONObject(sessionObj);
launchSession.setService(this);
return launchSession;
}
return null;
}