![]() |
远程intenting API
|
首 页 | 特色 | 安装 | 用户指南 | 应用开发API | 联系我们 |
简介 | 远程intenting | 组播通信 | 设备连 接 |
友机互联网提供类似的API来发送远程Intents,应用程序应该在AndroidManifest.xml中添加此权 限:
<uses-permission
android:name="com.xconns.peerdevicenet.permission.REMOTE_INTENT"
/>
请注意,当应用程序发送远程
intents 时,基于安全的原因,发送的 intents
不能直接使用设备的某些功能,例如摄像头,GPS等,因为这些功能需要特定的系统权限,友机互联网可能没有。 对于有这样需要的
intents,我们应该使用特别约定的intent,将它传送给接收设备的应用程序。
在接收的一端,要有一个应用程序,已经申请必要的系统权限,然后将接收到的特定的 intents 翻译成相应的系统的 intents。请
参照在 RemoteIntentDemo
应用程序的范例中,intents ACTION_DIAL 和 ACTION_CALL 是怎样处理的。
友机互联网提供了以下三 种的API支持远程 intenting
将需要传递的远程intent 加入“载体”,作为一个名为 “REMOTE_INTENT”的数据项目来传输:
carrierIntent.putExtra(“REMOTE_INTENT”,remote_intent);
设定软件包的名字 (可省去)
arrierIntent.putExtra(PACKAGE_NAME, ...);
当用 startService()发送远程 intent 时,必须设置目标设备的参数
当用 startActivity()发送远程 intent 时,如果设定的目标设备已经连接 好,友机互联网会直接发送信息;否则,友机互联网 会列出所有已经连接好的设备,用户可以选择一个或者多个设备作为发送目标。
如果远程 intent设定了软件包的名字,而且在接收设备上没有应用程序能够处理这个intent,友机互联网会提示去应用程序商店安装这个应 用。
请参考 RemoteIntentDemo 的应 用程序,了解如何使用startActivity()发送远程 intent。用户也可以从谷 歌Play直接安装使用这个程序。
这项服务将提供以下的异步界面:
IRemoteIntentService {使用这项服务的应用程序,需要登记具有以下界面的处理程序,来处理发送远程 intent 的各种状态:
oneway void startRemoteActivity(in DeviceInfo device, in Intent intent, IRemoteIntentHandler h);
oneway void startRemoteActivityForResult(in DeviceInfo device, in Intent intent, IRemoteIntentHandler h);
oneway void startRemoteService(in DeviceInfo device, in Intent intent, IRemoteIntentHandler h);
oneway void sendRemoteBroadcast(in DeviceInfo device, in Intent intent, IRemoteIntentHandler h);
oneway void cancelSession(int sessionId);
}
IRemoteIntentHandler {请参考这个使 用IDL API发送远程 intent的应用程序。
oneway void onError(in String errInfo);
oneway void onResult(in Intent result);
oneway void onStart(int sessionId);
oneway void onProgress(int percent);
oneway void onComplete();
oneway void onRejected();
oneway void onCanceled();
}
待定.