دنبال کننده ها

۱۳۹۶ تیر ۱۳, سه‌شنبه

android - Remote AIDL service returns null

[ad_1]



The AIDL library shall consist of few aidl files:
- IService
- IMusicPlayerManager
- IPlayer



There's a need to implement a remote service based on these AIDL files.



To make it simple, IService returns IMusicPlayerManager, and IMusicPlayerManager returns IPlayer.



Androud
After we connect to the service in onServiceConnected method we execute the following code:



 mService = ISecuredPlayer.Stub.asInterface(service);
IMusicPlayerManager mPlayerManager = mService.getMusicPlayerManager();
IPlayer mPlayer = mPlayerManager.createPlayer(mPlayerCallback);


Our service contains the following method:



@Override
public IMusicPlayerManager getMusicPlayerManager() throws RemoteException
return new MusicPlayerManagerImp();



The problem is that we are able to connect to the service, but when we call mService.getMusicPlayerManager(), the IMusicPlayerManager instance is null.



Please suggest what might be wrong.




[ad_2]

لینک منبع