Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aidl oneway keyword error

Tags:

android

aidl

I am implementing an aidl interface, and for some reason, the following code gives me an error:

// 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);
}

ERROR:

<interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package expected, got 'oneway'

When I remove the oneway keyword, everything works fine. But this cannot be the solution for my problem...

like image 230
PKlumpp Avatar asked Jul 28 '16 09:07

PKlumpp


1 Answers

Summary:

Move the oneway keyword to the method level.

Explanation-
This is very weird problem that related to the /platform/frameworks/base/api/current.txt file inside the Android framework (Big txt file that contains every function and being used by Android Studio) .

Example-

/** 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);
}

You will get the same result but without the error.

like image 65
Nir Duan Avatar answered Oct 07 '22 22:10

Nir Duan