[android] Catch 'app upgraded' intent.

(cherry picked from commit 7b8097f)
This commit is contained in:
Dmitry Yunitsky 2015-07-30 18:11:24 +03:00 committed by Alex Zolotarev
parent 32244da39d
commit 6081643ac7
5 changed files with 62 additions and 2 deletions

View file

@ -171,8 +171,8 @@
<activity
android:name="com.mapswithme.maps.MWMActivity"
android:launchMode="singleTask"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
android:theme="@style/MwmTheme.Map">
android:theme="@style/MwmTheme.Map"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
</activity>
<activity
@ -323,6 +323,25 @@
<category android:name="${applicationId}"/>
</intent-filter>
</receiver>
<!-- Catches app upgraded intent.
Different receivers are used due to MY_PACKAGE_REPLACED was added in Honeycomb_MR1-->
<receiver android:name=".background.UpgradeReceiver"
android:enabled="@bool/isNewerThanHoneycombMr1">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:name=".background.UpgradeReceiverCompat"
android:enabled="@bool/isOlderThanHoneycombMr1">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
</application>
</manifest>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="isNewerThanHoneycombMr1">true</bool>
<bool name="isOlderThanHoneycombMr1">false</bool>
</resources>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="isNewerThanHoneycombMr1">false</bool>
<bool name="isOlderThanHoneycombMr1">true</bool>
</resources>

View file

@ -0,0 +1,14 @@
package com.mapswithme.maps.background;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class UpgradeReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
// TODO our package's updated, do smth
}
}

View file

@ -0,0 +1,17 @@
package com.mapswithme.maps.background;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class UpgradeReceiverCompat extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
if (context.getPackageName().equals(intent.getData().getSchemeSpecificPart()))
{
// TODO our package's updated, do smth
}
}
}