2013-11-21 29 views
1

試圖遠程一些接口從Android應用程序服務到另一個客戶端應用程序,並使用AIDL方法..
所以我有一個接口IJobController在IJobController.aidl :
import com.example.jobs.api.IJobExecutionContext;如何返回活動對象的列表中的Android IPC

interface IJobController { 
    List<IJobExecutionContext> getCurrentlyExecutingJobs(); 
    ... 
} 

其中IJobExecutionContext在其自身的AIDL定義:

interface IJobExecutionContext {  
    Bundle getJobResult(); 
    ... 
    long getJobStartTime(); 
    long getJobEndTime(); 
    long getJobRunTime(); 
} 

當這些定義在文件夾進行編譯,我得到這樣的在生成IJobController.java文件錯誤:

Type mismatch: cannot convert from ArrayList<IBinder> to List<IJobExecutionContext> 
The method writeBinderList(List<IBinder>) in the type Parcel is not applicable for the arguments (List<IJobExecutionContext>) 

從我所瞭解的情況來看,這些接口可以與基本類型,Parcelable等一起用於List(或Map)中。 在另一個只返回AIDL接口的方法中,一切正常,但似乎在列表容器中不是。

我是否需要返回原始列表或IJobExecutionContext的實現列表,它也是可分組

謝謝。

回答

0

問題是,活頁夾不知道你的界面IJobExecutionContext,它不知道如何處理它。 Binder知道如何編組和解組僅僅是原始類型。在其他情況下,您需要解釋如何執行這些操作來實現Parcelable接口。因此,據我所知,你不能使用AIDL文件中的接口。您需要用實現此接口的類替換IJobExecutionContext。另外,這個類還必須實現Parcelable接口。