2

When a new application is installed , my BroadcastReceiver gets package data with a simple filter :

filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addDataScheme("package");

receiver = new newPackageReceiver();
registerReceiver(receiver, filter);

...

public class newPackageReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        final String info = intent.getData().toString();
            ...
            }
    }

BroadcastReceiver is called with most of devices... However, with this device (only in japanese, sorry), onReceive is never called.

  • model: sony SO-03D
  • android-version: 4.0.4

No update available for the device.... any ideas?

frogatto
  • 28,539
  • 11
  • 83
  • 129
johann
  • 1,115
  • 8
  • 34
  • 60

1 Answers1

1

Maybe this helps. Try to add the receiver to the manifest.

<receiver android:name=".YourReceiver">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_INSTALL" />
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <data android:scheme="package"/>
    </intent-filter>
</receiver>

And in YourReceiver class:

public class YourReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String act = intent.getAction();
        if (Intent.ACTION_PACKAGE_ADDED.equals(act) || Intent.ACTION_PACKAGE_REMOVED.equals(act)) {
            //Do what you want
        }
}

I hope this would help, but it seems that the problem is with this device's rom.

Sina Masnadi
  • 1,516
  • 17
  • 28