Search code examples
javaandroidandroid-4.2-jelly-bean

android.intent.action.PACKAGE_ADDED BroadcastReceiver not receiving theme added intent on JB 4.1


I am using BroadcastReceiver in my android application, I am running my app on JB 4.1

in manifest I have registered as

<receiver android:name=".ThemeInstalledBroadcastReceiver" android:enabled="true">
    <intent-filter android:priority="100">
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <action android:name="android.intent.action.PACKAGE_REMOVED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

when I install any application ThemeInstalledBroadcastReceiver class gets triggered but when I install some theme then ThemeInstalledBroadcastReceiver wont get triggered. But this application works fine when I run it on JB 4.2

My Receiver code goes like this

public class ThemeInstalledBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, final Intent arg1) {
        System.out.println("Mass_TC inside InstalledBroadcastReceiver res " + arg1.getAction().equals(Intent.ACTION_PACKAGE_ADDED) );
        System.out.println("Mass_TC apkid " + arg1.getData().getEncodedSchemeSpecificPart() + " intent : " + arg1);

    }

}

Logs when I install apps

I/System.out(19647): Mass_TC apkid com.example.ttest intent : Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.ttest flg=0x8000010 cmp=com.myrrom.themechooser/.InstalledBroadcastReceiver (has extras) }
I/System.out(19647): Mass_TC deleting apkid  : com.example.ttest x : 0
I/System.out(19647): Mass_TC inside InstalledBroadcastReceiver res true
I/System.out(19647): Mass_TC apkid com.example.test_fa intent : Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.test_fa flg=0x8000010 cmp=com.myrrom.themechooser/.InstalledBroadcastReceiver (has extras) }
I/System.out(19647): Mass_TC deleting apkid  : com.example.test_fa x : 0

but when I install any theme I dont get any logs


Solution

  • Some how I figured out the solution.

    I added category to my intent filter

    <category android:name="com.tmobile.intent.category.THEME_PACKAGE_INSTALL_STATE_CHANGE" />