Reputation: 6009
I need to pass an Intent
object to remote service through AIDL, I tried:
In aidl file:
import android.content.Intent;
parcelable Intent
void passIntent(Intent intent);
In my remote serivce class:
private final IMyService.Stub mBinder = new IMyService.Stub() {
//ERROR: The method must override or implement a supertype method
@Override
public void passIntent(Intent intent) {
}
}
I got compilation error The method must override or implement a supertype method
.
Then I checked gen/ folder, IMyService.java, the method is not generated. Project clean & re-build doesn't help.
Why? Does Android not allow to pass Intent
object in this way? If so, how can I pass Intent
object from Activity to service in another process?
Upvotes: 2
Views: 2084
Reputation: 1007369
When I created a new Android Studio project and defined this AIDL based on your question:
package com.commonsware.myapplication;
import android.content.Intent;
interface IMyService {
void passIntent(Intent intent);
}
I received a build error:
.../IMyService.aidl:6 parameter 1: 'Intent intent' can be an out parameter, so you must declare it as in, out or inout.
Changing the AIDL to:
package com.commonsware.myapplication;
import android.content.Intent;
interface IMyService {
void passIntent(in Intent intent);
}
resulted in IMyService.java
being generated with the proper method.
So, add the in
keyword to your passIntent()
declaration, and try that.
Upvotes: 1