将广播从一个APK/程序包发送到另一APK/程序包

问题描述:

我需要将广播从我的一个应用程序发送到另一个应用程序.任何帮助! 我的应用程序包是1)com.demo.database和2)com.demo.list

I need to send broadcast from my one application to another applicaion.. any help! my application package are 1)com.demo.database and 2)com.demo.list

 Intent themesIntent = new Intent(ThemesManager.THEMES_UPDATED);
 themesIntent.putExtra("package", packageName);
 ctx.sendBroadcast(themesIntent);

不起作用.

<receiver android:name="com.sample.ThemesUpdatedReceiver">
        <intent-filter>
            <action android:name="com.sample.THEMES_UPDATED"/>
        </intent-filter>
    </receiver>

@Ajit:由于Android API 3.0 [API级别11],如果一个应用程序从未启动过一次,那么它的BroadcastReceiver就无法接收事件.就您而言,您的应用没有启动器活动,因此可能是导致事件被拒绝的原因.

@Ajit: Hi, Since Android API 3.0 [API level 11], If an application has never been started even once, then it's BroadcastReceiver can't receive events.As, in your case, your app has no launcher activity, so may be it is the case that causes rejection of event.

与此同时,请尝试使用以下方法: 您在创建Intent对象时已传递了该常数值.而是将其传递给方法intent.setAction();

Along with that please try using below approach: You have passed that constant value while creating Intent object. Instead pass it in method intent.setAction();

希望这会有所帮助.