OK, I found a solution, but I feel sick for what it is...

After reading about how classes declared in the manifest should never 
change, I went and creating each class in the manifest as a class in the 
app, extending the corresponding class in the library. Then, I had to 
change every Intent to include the correct class, using forName. So, and 
example of this scenario is:

app package: com.sample.package
activity: MyActivity

library: com.sample.package.core
activity: MyActivity

There's a MyActivity in the app, and a MyActivity in the library. The 
MyActivity in the app simply extends com.sample.package.core.MyActivity.

Then, any occurrence of...

new Intent(context, MyActivity.class)

...in the library must become...

new Intent(context, Class.forName(context.getPackageName() + "." + 
MyActivity.class.getSimpleName());

If there's a way to do this through the manifest, please let me know!

Thank you


On Wednesday, June 13, 2012 1:23:31 PM UTC-4, Bryan wrote:
>
> Hi,
>
> I've 2 versions of an app, for which I just merged the code into a single 
> library that I reference from both apps. In testing, I found that if an 
> appwidget existed on the homescreen for this app and I updated to the new 
> version using the library, the LauncherModel.java would delete the widget, 
> logging 
> "Log.e<http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/android/util/Log.java#Log.e%28java.lang.String%2Cjava.lang.String%29>
> (TAG<http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/2.3_r1/com/android/launcher2/LauncherModel.java#LauncherModel.0TAG>
> , "Deleting widget that isn't installed anymore: id=" 
>
> + id + " appWidgetId=" + appWidgetId);". I found that this was due to the 
> change in the AppWidgetProvider in the manifest. It changed to reference the 
> class that moved to the library. To resolve that, I moved the class back out 
> of the library and directly into the project and reverted the manifest for 
> those receivers. This resolved the "deleting widget..." error, but now the 
> widget isn't rendered by the launcher at all after testing the update. I 
> checked /data/system/appwidgets.xml, and the widget is still listed there. 
> The appwidgetprovider is still called and my service runs, pushing the 
> update, but there's no widget on the homescreen. It's not invisible, as I can 
> long press on the area where the widget was and I get the wallpaper choser. 
> Why isn't the widget fully preserved across this updated?
>
> To clarify, my testing procedure is this, on an emulator with API Level 15:
>
> 1. Install version 1 of app
>
> 2. Add a homescreen widget
>
> 3. Update to version 2 of app
>
> 4. Widget remains
> 5. Update to version 3 of app, with code moved to library
>
> 6. Widget is gone, but traces still exist. The appwidgetmanager still 
> recognizes it when calling getAppWidgetIds or getAppWidgetInfo
>
> Any help would be great as I'm getting no information from the logs.
>
>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to