Reputation: 1135
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.
No update available for the device.... any ideas?
Upvotes: 2
Views: 2224
Reputation: 1556
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.
Upvotes: 1