after tinkering for a while, here's what i've come up against --
in my AndroidManifest.xml file, I added these lines --
<receiver android:name="com.test.gui.UpdateReceiver">
<intent-filter>
<action
android:name="android.intent.action.PACKAGE_ADDED"/>
<action
android:name="android.intent.action.PACKAGE_REMOVED"/>
<action
android:name="android.intent.action.PACKAGE_REPLACED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
which allows me to have UpdateReceiver.java
package com.slacker.gui;
import com.test.appwidget.TestAppWidgetProvider;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class UpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.compareTo(Intent.ACTION_PACKAGE_REMOVED) == 0) {
Log.e("UpdateReceiver", "ACTION_PACKAGE_REMOVED");
Intent broadcastIntent = new Intent(context,
TestAppWidgetProvider.class);
broadcastIntent.setAction
(TestAppWidgetProvider.ACTION_PACKAGE_REMOVED);
context.sendBroadcast( broadcastIntent );
}
}
}
and in my app widget provider subclass, I have --
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (TestAppWidgetProvider.ACTION_PACKAGE_REMOVED.equals
(action)) {
this.onRemoved(context);
}
}
And in my onRemoved method, I have --
public void onRemoved(Context context) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.appwidget);
// re-initialize the remote view.
ComponentName thisWidget = new ComponentName(context,
TestAppWidgetProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance
(context);
manager.updateAppWidget(thisWidget, remoteViews);
}
And after i do all this, the remote view is not updated. What am I
doing wrong?
tia.
On Nov 18, 10:22 am, sdphil <[email protected]> wrote:
> can someone explain how re-installing (from an old version of your app
> to a new version of your app) works with respect to an app widget?
>
> specifically, it does not seem like app widgets get replaced with a re-
> install.
>
> tia.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en