繁体   English   中英

Android AIDL 服务未执行

[英]Android AIDL Service not executing

我使用 Android Automotive 11 环境,下面的代码实际上也不能在常规 Android 11 环境下运行。

我使用从源代码 Android 11 r35 构建的模拟器。

当我尝试打开 AIDL 服务时,出现以下错误:

PermissionMonitor:NameNotFoundException

BroadcastQueue:不允许后台执行在此处输入图像描述

这是代码:

public class MySimpService extends Service {

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return new SimpServiceImp();
    }
}

SimpServiceImp Class:

public class SimpServiceImp extends ISimp.Stub {

    @Override
    public int add(int a, int b) throws RemoteException {
        return a+b;
    }

    @Override
    public int sub(int a, int b) throws RemoteException {
        return a-b;
    }
}

AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AIDLService" >

    <service android:name=".MySimpService">
        <intent-filter>
            <action android:name="com.example.aidlservice.MySimpService"/>
        </intent-filter>
    </service>
</application>

有很多基本的 Android 问题使得这不起作用。 部分原因是服务必须有通知才能保持活力。

https://github.com/NewstHet/AndroidAidlClient https://github.com/NewstHet/AndroidAIDLService

Github 链接包含使用 Android 11 API 30 的工作 AIDL 服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM