Android—是否可以在远程服务上调用未公开的公共方法';语境
我有一个远程服务,一个远程服务接口和一个客户端绑定到它。我想知道是否有可能在服务中调用未在服务上下文的接口中公开的方法(例如UnposedMethod2) 我的代码如下: SomeService.java:Android—是否可以在远程服务上调用未公开的公共方法';语境,android,service,aidl,Android,Service,Aidl,我有一个远程服务,一个远程服务接口和一个客户端绑定到它。我想知道是否有可能在服务中调用未在服务上下文的接口中公开的方法(例如UnposedMethod2) 我的代码如下: SomeService.java: public class SomeService extends IntentService { private IRemote.Stub iremote_sub = new IRemote.Stub(){ public String SomeMethod(Strin
public class SomeService extends IntentService {
private IRemote.Stub iremote_sub = new IRemote.Stub(){
public String SomeMethod(String key) throws RemoteException {
return SomeService.this.UnexposedMethod1(key);
}
};
private String UnexposedMethod1(String key){
/* Do Something With key */
........................
return UnexposedMethod2();
}
public String UnexposedMethod2(){
String str = new String();
/* Do Something With str and Fetch Data from Providers */
return str;
}
}
IRemote.aidl:
interface IRemote{
String SomeMethod(String key)
}
SomeActivity.java:
public class SomeActivity extends Activity {
private ServiceConnection myConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
myService = IGetContactsString.Stub.asInterface(service);
/* Can I call UnexposedMethod2 here on service's context? */
}
public void onServiceDisconnected(ComponentName className) {
myService = null;
}
};
}
任何建议都是有用的。非常感谢 你真的需要吗?谢谢你的回复。在这种情况下,只有远程服务具有提供者的权限,所以我认为所有移动都应该在服务的上下文中进行。看来需要艾德尔@肯沃尔夫