Reputation: 21
I have a little problem with widgets availability in menu "desktop->add->widget->". I can't figure out why my widgets are not accessible on small screen (ldpi) and when it has been moved to sdcard. Manifest
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:process="@string/app_name"
android:persistent="true" android:debuggable="false"
android:description="@string/app_desc">
<receiver android:name="widget.Widget_4_1" android:label="Rozmiar 4x1">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_4_1" />
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Widget Provider
<?xml version="1.0" encoding="utf-8" ?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dip"
android:initialLayout="@layout/widget41"
android:updatePeriodMillis="@string/UpdatePeriod"
android:minHeight="72dip"/>
Layout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Widget41"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:background="@drawable/frame41"
android:layout_width="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/widgettextview41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:textColor="@android:color/black"
android:text="@string/widget_loading"
android:padding="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:textSize="5pt" />
</LinearLayout>
Any help is appreciated
Upvotes: 0
Views: 481
Reputation: 11
I had the same problem recently. The problem was the value of android:updatePeriodMillis
in widget provider. It looks like you cannot reference a value from resources in this place. So replacing the reference with actual number (eg. 1800000) fixes the problem.
That worked on SE Xperia X10 mini pro with Android 2.1. I had no such problems on devices running Android 2.2.
Upvotes: 1
Reputation: 6965
re: moving to sdcard and losing the widget
http://developer.android.com/guide/appendix/install-location.html#ShouldNot "... you should not allow your application to be installed on the external storage if it uses any of the following features ... App Widgets ..."
ie, it's a known and documented limiation.
re: ldpi,
not sure if it will solve it for you, but if in uses-sdk you set minSdkVersion to whatever is appropriate and set targetSdkVersion to something high (eg 11 stating honeycomb compat), then you don't need supports-screens as targetSdkVersion effectivly implies / sets defaults for all sizes supported by targetSdkVersion.
Upvotes: 1