jeudi 13 août 2015

Can someone help me with aidl while using android:process?

I wrote an aidl service and set android:process=".remote" in AndroidManifest, but I can only get the original data and while the data updated, the data I get doesn't change. But while I delete the android:process it works. Why did this happen and how does android:process works?

for example: aidl:

interface ILoginInfoService {
    String getLoginInfo();
}

TestService:

public class TestService extends Service {
    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }
    private final ILoginInfoService.Stub mBinder = new ILoginInfoService.Stub() {
        @Override
        public String getLoginInfo() throws RemoteException {
            return TestClass.string;
        }
    };
}

TestClass:

public class TestClass {
    static String string = "a";
}

TestActivity:

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        TestClass.string += "a";
        try {
            if(mRemoteService.getLoginInfo() != null) {
                textView.setText(mRemoteService.getLoginInfo());
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
});

it only shows "a" while i click the button, but if i delete the android:process below ,the string will increase("a", "aa", "aaa", ...).

<service android:name=".TestService" android:process=".remote">
    <intent-filter>
        <action android:name="com.example.chayne_shen.testservice.TestService" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</service>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire