本文介绍了如何申报一个Receiver类是在外部库present意向过滤器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个库中的一个,其的类

I've created a library one of whose class is

public class SmsReceiver extends BroadcastReceiver{...}

现在,因为这个类扩展BroadcaseReceiver所以我需要声明的意图过滤器是这样的:

Now since this class extends BroadcaseReceiver so I need to declare intent-filter like this:

<receiver android:name="SmsReceiver">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

不过,现在既然SmsReceiver类是外部库的一部分,所以,如果我声明意图过滤器类似上面的应用程序(应用程序包是com.abc.test)这里我使用了SmsReceiver类,我得到一个错误中说

But, now since the SmsReceiver class is a part of external library so, if I declare the intent-filter like above in the application (application package is com.abc.test) where I'm using the SmsReceiver class, I get an error in the AndroidManifest.xml which says

Class com.abc.test.SmsReceiver doesn't exist

我需要做的就是它的工作?该库已经包含在项目构建路径,我能够从应用程序(com.abc.test)调用SmsReceiver类。唯一的问题是,广播接收器(我们SmsReciever类)将无法工作。

What I need to do to get it working? The library has been included in the project build path and I'm able to call the SmsReceiver class from the app (com.abc.test). The only problem is that the BroadcastReceiver (our SmsReciever class) won't work.

推荐答案

使用的android:NAME =the.fully.qualified.class.name.SmsReceiver,其中 the.fully.qualified.class.name.SmsReceiver SmsReceiver 类的完全限定类名。

Use android:name="the.fully.qualified.class.name.SmsReceiver", where the.fully.qualified.class.name.SmsReceiver is the fully-qualified class name of the SmsReceiver class.

这篇关于如何申报一个Receiver类是在外部库present意向过滤器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:03