android.content.Contextを実装していないため、使用は機能しませんandroid.os.Parcelable。
ただし、-ff(MyExampleParcelableたとえば)AIDLインターフェイスで転送するクラス(および実際に実装するクラス)がある場合は、ファイルParcelableを作成し、その中に次のように記述します。.aidlMyExampleParcelable.aidl
package the.package.where.the.class.is;
parcelable MyExampleParcelable;
さて、プロセス間で必死に話したいのでなければ、ローカルサービスを検討する必要があります。
編集(もう少し役立つ):
これはローカルサービスですか(つまり、独自のアプリケーションとプロセス内でのみ使用されます)?このような場合、通常はバインダーを実装して直接返す方がよいでしょう。
public class SomeService extends Service {
....
....
public class SomeServiceBinder extends Binder {
public SomeService getSomeService() {
return SomeService.this;
}
}
private final IBinder mBinder = new SomeServiceBinder();
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
public void printToast(Context context, String text) {
// Why are you even passing Context here? A Service can create Toasts by it self.
....
....
}
// And all other methods you want the caller to be able to invoke on
// your service.
}
基本的に、Activityがサービスにバインドされると、結果IBinderをキャストしSomeService.SomeServiceBinder、呼び出しSomeService.SomeServiceBinder#getSomeService()、実行中のインスタンスへのアクセスを呼び出しService、APIで何かを呼び出すことができます。