通过AIDL投掷无法启动服务意图来调用AAR图书馆服务



我在我的Android应用程序中包含了一个AAR库。以及库清单文件中的任何活动,服务,接收器,我都将其复制到应用程序清单文件中。

现在,我想通过AIDL调用图书馆的服务。当我启动服务时,请获得"无法启动服务意图"

有人可以帮助我要做什么才能使它起作用?操作系统如何告诉该服务在库中可用?

AAR文件库软件包名称为" com.abc.lib"。AAR清单文件中的服务:

    <service android:name="com.abc.lib.MyService"
       android:exported="true">
       <intent-filter>
           <action android:name="com.abc.lib.aidl.IMyService"/>
       </intent-filter>
    </service>

使用以下代码从应用程序活动文件调用上述服务:

ComponentName compName = null;
Intent i = new Intent("com.abc.lib.aidl.IMyService");
i.setPackage("com.abc.lib");
compName = startService(i);
return compName;

提前谢谢。

而不是在intent.setpackage中的库软件包,我尝试了应用程序包,它起作用。

ComponentName compName = null;
Intent i = new Intent("com.abc.lib.aidl.IMyService");
i.setPackage("com.abc.application");  //Instead of library package-give the application package
compName = startService(i);
return compName;

最新更新