无法启动从包含应用程序库的意图 [英] Unable to start intent from application containing library

查看:103
本文介绍了无法启动从包含应用程序库的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:我要开始这是坐落在连接库项目的服务。所有关于类在库中。

Hi: I want to start a service which is situated in a connected library project. All concerning classes are in the library.

该服务是从位于库的活动名为:

The service is called from an activity located in the library:

Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
startService(serviceIntent);

在清单文件,这两种都是在图书馆和针对应用它指出:

In the manifest files -both at library and application- it is noted:

    <service android:name="org.example.library.SomeLibraryClass">
        <intent-filter>
            <action android:name="org.example.library.MY_ACTION" />
        </intent-filter>
    </service>

无法启动服务意向{行动= org.example.android.SomeLibraryClass(有演员)}:找不到

好像Android是寻找应用程序,但不是在图书馆的一类。任何人收到这种行为?

It seems like Android is looking for a class in the application but not in the library. Anyone had this behavior before?

推荐答案

您需要调用库中定义的意图时,指定应用程序的软件包:

You need to specify the package of the application when calling an Intent defined in a library:

Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
serviceIntent.setPackage("org.example.application");
startService(serviceIntent);

这篇关于无法启动从包含应用程序库的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆