I am using ACTION_MY_PACKAGE_REPLACED to receive when my app is updated or resinstalled. My problem is that the event is never triggered (I tried Eclipse and real device). T
Getting information from all the users I could solve my situation this way. All of them were right, with little points to notice:
In manifest:
And code:
public class MyEventReceiver extends BroadcastReceiver
{
@Override public void onReceive(Context context, Intent intent)
{
if(Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()))
{ if(intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
{ //Restart services.
}
}
}
}
In my Android release (2.3 Gingerbread) I was not able to use MY_PACKAGE_REPLACED but we solved using PACKAGE_REPLACED (will advise of any app been replaced) but asking if it is ours with:
if(intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
{
}
Thanks to all