aidl oneway关键字错误

PKl*_*mpp 7 android aidl

我正在实现一个aidl接口,由于某种原因,下面的代码给了我一个错误:

// IApkinsonCallback.aidl
package com.applications.philipp.apkinson.interfaces;

/** Interface implemented by Apkinson so plugins can give feedback */
oneway interface IApkinsonCallback {
    /** To be called by plugin after registration to setup data for result viewing
        Usage of this data:
        Intent intent = new Intent(intentActionName);
        intent.putExtra(bundleResultKey, result);
        startActivity(intent);
     */
    void onRegistered(String intentActionName, String bundleResultKey);
    /** To be called by plugin when result is ready after stopData() was called by Apkinson */
    void onResult(String result);
    /** Called if an error occured in the plugin and the call won't be successfully handled */
    void onError(String errorMsg);
}
Run Code Online (Sandbox Code Playgroud)

错误:

<interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'
Run Code Online (Sandbox Code Playgroud)

当我删除oneway关键字时,一切正常.但这不能解决我的问题......

Nir*_*uan 8

摘要:

oneway关键字移动到方法级别.

解释 -
这是与/platform/frameworks/base/api/current.txtAndroid框架内的文件相关的非常奇怪的问题(包含所有功能并由Android Studio使用的Big txt文件).

例-

/** Interface implemented by Apkinson so plugins can give feedback */
interface IApkinsonCallback {
    /** To be called by plugin after registration to setup data for result viewing
        Usage of this data:
        Intent intent = new Intent(intentActionName);
        intent.putExtra(bundleResultKey, result);
        startActivity(intent);
     */
    oneway void onRegistered(String intentActionName, String bundleResultKey);
    /** To be called by plugin when result is ready after stopData() was called by Apkinson */
    oneway void onResult(String result);
    /** Called if an error occured in the plugin and the call won't be successfully handled */
    oneway void onError(String errorMsg);
}
Run Code Online (Sandbox Code Playgroud)

您将得到相同的结果,但没有错误.

  • 如果您了解原因,请在此标记我! (2认同)