aidl oneway 关键字错误
aidl oneway keyword error
我正在实现一个 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);
}
错误:
<interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'
当我删除 oneway
关键字时,一切正常。但这不能解决我的问题...
总结:
将 oneway
关键字移动到方法级别。
说明-
这是一个与 Android 框架内的 /platform/frameworks/base/api/current.txt
文件相关的非常奇怪的问题(包含每个函数并被 Android Studio 使用的大 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);
}
您将得到相同的结果,但没有错误。
我在 Android Studio 4.1 上测试,我看到了
oneway interface IApkinsonCallback {
void valueChange();
}
// AndroidStudio dislay error: <interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'
// BUT it compiles ok and work ok
// AND ALL METHOD INSIDE INTERFACE is oneway method
.
interface IApkinsonCallback {
oneway void valueChange(); // WORK AS EXPECTED, asynchronous remote call
int getData(); // WORK AS EXPECTED, synchronous remote call
oneway int getData(); // COMPILE ERROR: oneway method 'getData' cannot return a value
}
我正在实现一个 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);
}
错误:
<interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'
当我删除 oneway
关键字时,一切正常。但这不能解决我的问题...
总结:
将 oneway
关键字移动到方法级别。
说明-
这是一个与 Android 框架内的 /platform/frameworks/base/api/current.txt
文件相关的非常奇怪的问题(包含每个函数并被 Android Studio 使用的大 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);
}
您将得到相同的结果,但没有错误。
我在 Android Studio 4.1 上测试,我看到了
oneway interface IApkinsonCallback {
void valueChange();
}
// AndroidStudio dislay error: <interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'
// BUT it compiles ok and work ok
// AND ALL METHOD INSIDE INTERFACE is oneway method
.
interface IApkinsonCallback {
oneway void valueChange(); // WORK AS EXPECTED, asynchronous remote call
int getData(); // WORK AS EXPECTED, synchronous remote call
oneway int getData(); // COMPILE ERROR: oneway method 'getData' cannot return a value
}