本文整理汇总了Java中com.connectsdk.service.sessions.LaunchSession类的典型用法代码示例。如果您正苦于以下问题:Java LaunchSession类的具体用法?Java LaunchSession怎么用?Java LaunchSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LaunchSession类属于com.connectsdk.service.sessions包,在下文中一共展示了LaunchSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:25,代码来源:DIALService.java
示例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);
}
});
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:21,代码来源:WebOSTVService.java
示例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);
}
});
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:18,代码来源:WebOSTVService.java
示例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();
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:26,代码来源:WebOSTVService.java
示例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();
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:19,代码来源:WebOSTVService.java
示例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();
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:18,代码来源:WebOSTVService.java
示例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);
}
});
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:20,代码来源:WebOSTVService.java
示例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"));
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:21,代码来源:WebOSTVServiceTest.java
示例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);
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:27,代码来源:CastService.java
示例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();
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:26,代码来源:WebOSTVService.java
示例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);
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:9,代码来源:CastService.java
示例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);
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:28,代码来源:CastService.java
示例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));
}
}
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:32,代码来源:CastService.java
示例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;
}
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:42,代码来源:DeviceService.java
示例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;
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:11,代码来源:DLNAService.java
示例16: 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();
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:16,代码来源:NetcastTVService.java
示例17: getAppState
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void getAppState(final LaunchSession launchSession, final AppStateListener listener) {
String requestURL = String.format(Locale.US, "%s%s",
getUDAPRequestURL(UDAP_PATH_APPTOAPP_DATA),
String.format(Locale.US, "/%s/status", launchSession.getAppId()));
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
Util.postError(listener, error);
}
@Override
public void onSuccess(Object object) {
String response = (String) object;
AppState appState;
if (response.equalsIgnoreCase("NONE"))
appState = new AppState(false, false);
else if (response.equalsIgnoreCase("LOAD"))
appState = new AppState(false, true);
else if (response.equalsIgnoreCase("RUN_NF"))
appState = new AppState(true, false);
else if (response.equalsIgnoreCase("TERM"))
appState = new AppState(false, true);
else
appState = new AppState(false, false);
Util.postSuccess(listener, appState);
}
};
ServiceCommand<ResponseListener<Object>> command = new ServiceCommand<ResponseListener<Object>>(this, requestURL, null, responseListener);
command.setHttpMethod(ServiceCommand.TYPE_GET);
command.send();
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:37,代码来源:NetcastTVService.java
示例18: closeMedia
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public void closeMedia(LaunchSession launchSession, ResponseListener<Object> listener) {
if (getDLNAService() == null) {
Util.postError(listener, new ServiceCommandError(0, "Service is not connected", null));
return;
}
getDLNAService().closeMedia(launchSession, listener);
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:10,代码来源:NetcastTVService.java
示例19: sendMessage
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
public void sendMessage(String message, LaunchSession launchSession, ResponseListener<Object> listener) {
if (message != null && message.length() > 0) {
sendMessage((Object) message, launchSession, listener);
}
else {
Util.postError(listener, new ServiceCommandError(0, "Cannot send a null message", null));
}
}
开发者ID:PTCE,项目名称:popcorn-android,代码行数:9,代码来源:WebOSTVService.java
示例20: subscribeAppState
import com.connectsdk.service.sessions.LaunchSession; //导入依赖的package包/类
@Override
public ServiceSubscription<AppStateListener> subscribeAppState(
LaunchSession launchSession,
com.connectsdk.service.capability.Launcher.AppStateListener listener) {
// TODO Auto-generated method stub
return null;
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:8,代码来源:DIALService.java
注:本文中的com.connectsdk.service.sessions.LaunchSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论