Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>see this:</p> <p><a href="https://stackoverflow.com/questions/2133986/how-to-know-my-android-application-has-been-upgraded-in-order-to-reset-an-alarm">How to know my Android application has been upgraded in order to reset an alarm?</a></p> <p>correct fix is that you use the wrong string in the manifest: <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED" rel="noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED</a></p> <p>it should be "android.intent.action.PACKAGE_REPLACED" instead.</p> <hr> <p>ok , i see that what i've written is still not enough to try it out, so i will make an exception and publish a whole project just to show that it works: app code is in a package called "com.broadcast_receiver_test" . don't forget to run it before testing , or else it won't work on some android versions (i think API 11+) .</p> <p>manifest:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.broadcast_receiver_test" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-sdk android:minSdkVersion="3" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name"&gt; &lt;activity android:name=".BroadcastReceiverTestActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;receiver android:name=".MyBroadcastReceiver"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.PACKAGE_REPLACED"/&gt; &lt;data android:scheme="package" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.PACKAGE_REMOVED"/&gt; &lt;data android:scheme="package" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.PACKAGE_ADDED"/&gt; &lt;data android:scheme="package" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>MyBroadcastReceiver.java:</p> <pre><code>public class MyBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context,final Intent intent) { final String msg="intent:"+intent+" action:"+intent.getAction(); Log.d("DEBUG",msg); Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); } } </code></pre> <p>please just run it and see that it works perfectly .</p> <hr> <p>EDIT: if your app is for API12 and above, and only wish to handle the case of updating of your app, you can use this intent alone:</p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_MY_PACKAGE_REPLACED" rel="noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_MY_PACKAGE_REPLACED</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload