Android 来自不同项目的AIDL服务
我在eclipse中的同一个工作区中有2个不同的项目*(大多数AIDL示例在同一个项目中处理不同的过程)。项目A只是HelloWorld,它只显示2个数字的总和。我从一个叫做MyFirstApp的客户端远程调用它来显示它 问题:从未调用onServiceConnected()方法 到目前为止我所尝试的: 1)清单文件有android:process=“:remote”>标记。存在意向筛选器。是的,所有这些都在应用程序标签中。这是:Android 来自不同项目的AIDL服务,android,eclipse,aidl,Android,Eclipse,Aidl,我在eclipse中的同一个工作区中有2个不同的项目*(大多数AIDL示例在同一个项目中处理不同的过程)。项目A只是HelloWorld,它只显示2个数字的总和。我从一个叫做MyFirstApp的客户端远程调用它来显示它 问题:从未调用onServiceConnected()方法 到目前为止我所尝试的: 1)清单文件有android:process=“:remote”>标记。存在意向筛选器。是的,所有这些都在应用程序标签中。这是: <service android:name=".Arith
<service android:name=".ArithmeticService"
android:process=":remote">
<intent-filter >
<action android:name="com.example.helloworld.ArithmeticService"/>
</intent-filter>
</service>
</application>
@Override
public IBinder onBind(Intent intent) {
// Return the interface
Log.d(getClass().getSimpleName(),"IBinder");
return mBinder;
}
3)在客户端,接口的实现在服务器端的同一个包中
4)在客户端MainActivity的onCreate()函数中,我调用函数initConnection(),如下所示:
void initConnection(){
mServiceConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
mService = null;
Toast.makeText(getApplicationContext(), "no", Toast.LENGTH_SHORT).show();
Log.d("IRemote", "Binding - Service disconnected");
}
@Override
public void onServiceConnected(ComponentName name, IBinder service)
{
// TODO Auto-generated method stub
mService = IRemote.Stub.asInterface((IBinder) service);
Toast.makeText(getApplicationContext(), "yes", Toast.LENGTH_SHORT).show();
Log.d("IRemote", "Binding is done - Service connected");
}
};
if(mService == null)
{
Intent it = new Intent();
it.setAction("com.example.helloworld.ArithmeticService");
//binding to remote service
bindService(it, mServiceConnection, Service.BIND_AUTO_CREATE);
}
}
代码的其余部分相当简单。单击按钮时,应调用远程服务器,并显示2个数字的总和
任何帮助都将不胜感激。经过几天的努力才得到:项目的名称应该是小写的。这是Eclipse怪癖还是Android怪癖?我不知道但它是有效的。经过几天的尝试后得到了它:项目的名称应该是小写的。这是Eclipse怪癖还是Android怪癖?我不知道但它可以工作。我得到的错误是,“无法启动服务意图{act=com.example.helloworld.ArithmeticService}U=0未找到错误是,“无法启动服务意图{act=com.example.helloworld.ArithmeticService}U=0未找到”