Thursday, June 24, 2010

Re: [android-developers] Re: Alarms after an update ?

On Thu, Jun 24, 2010 at 11:56 AM, mac-systems <jens.hohl@gmx.de> wrote:
> Ok, i thought i have to do this.
> Is there any Intent which get broadcasted on update ? Or simlar
> mechanism ?

You can add a receiver for PACKAGE_REPLACED
<receiver android:name=".OnPackageChangeStarter">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<!-- This doesn't work
<data android:scheme="package" android:path="your.package.name" />
-->
</intent-filter>
</receiver>

and in the OnPackageChangeStarter, add an if

if(! intent.getDataString().startsWith("package:your.package.name")){
return;
}

At least on 2.1 Droid, the "intent.getData().getPath()" portion of
the intent is null, so the intent-filter doesn't seem to work.
Including it gets my receiver called for every package change.
The package name is in the "intent.getData().getSchemeSpecificPart()"

Anyone know if this is a bug? Or is this the right way to accomplish this?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment