I want start my application after upgrade. I used both android.intent.action.MY_PACKAGE_REPLACED and android.intent.action.PACKAGE_REPLACED actions.But it's never calling to my onReceive method. Min SDK version of my app is 21. This app does not contain activity class.Only a service. I created this app for launching my another android application in this device.
Here is Manifest code
<application
android:name=".DeviceAdminApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name=".SchedulerJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name=".AdminBroadcastReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name=".AppInstalledReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<data android:scheme="package" android:path="com.pnct.agent"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" android:path="com.pnct.agent"/>
</intent-filter>
</receiver>
</application>
here is the onReceive method
public class AppInstalledReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(Constants.LOGTAG, "inside on receive");
Log.d(Constants.LOGTAG, "action:"+intent.getAction());
if(intent.getAction().equalsIgnoreCase("android.intent.action.MY_PACKAGE_REPLACED") ||
(intent.getAction().equalsIgnoreCase("android.intent.action.PACKAGE_REPLACED"))){
Log.d(Constants.LOGTAG, "package replaced");
}}
If I install any other application,then onReceive method get called. Please help me to solve this problem thanks.