How to declare an intent-filter for a Receiver class which is present in an external library.

好久不见. 提交于 2019-12-11 07:39:49

问题


I've created a library one of whose class is

public class SmsReceiver extends BroadcastReceiver{...}

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>

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/6858070/how-to-declare-an-intent-filter-for-a-receiver-class-which-is-present-in-an-exte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!