Widget not registering with Android System -
i trying add together widget home screen allows users view database information. unfortunately seems cannot widget register android system.
here manifest file:
<reciever android:name="com.money.easymoney.freecashwidget" android:label="free cash widget 4x1" android:icon="@drawable/ic_launcher"> <intent-filter> <action android:name="android.appwidget.action.appwidget_update"/> <meta-data android:name="android.appwidget.appwidgetprovider" android:resource="@xml/freecashwidget"/> </intent-filter> </reciever> </application> here widget-provider in res/xml/freecashwidget.xml
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="294dp" android:minheight="72dp" android:minresizeheight="72dp" android:minresizewidth="294dp" android:updateperiodmillis="0" android:previewimage="@drawable/ic_launcher" android:initiallayout="@layout/freecashwidget" android:resizemode="none"> </appwidget-provider> here layout code:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="294dp" android:layout_height="72dp" android:padding="@dimen/widget_margin"> <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:clickable="false" android:background="@drawable/rectangle"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="free cash:" android:id="@+id/textwidgetfreecash" android:textsize="30sp" android:layout_alignparentleft="true" android:layout_centervertical="true"/> <button style="?android:attr/buttonstylesmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/buttonrecordexpense" android:background="@drawable/ic_action_spend" android:layout_alignparenttop="true" android:layout_alignparentright="true"/> </relativelayout> </relativelayout> here receiver:
public class freecashwidget extends appwidgetprovider { public void onupdate(context context, appwidgetmanager appmanager, int[] widgets) { super.onupdate(context, appmanager, widgets); final int n = widgets.length; for(int = 0; < n; i++) { int widgetid = widgets[i]; //create intent launch specified activity intent intent = new intent(context, main.class); pendingintent pintent = pendingintent.getactivity(context, 0, intent, 0); //get layout , attach onclicklistener button remoteviews view = new remoteviews(context.getpackagename(), r.layout.freecashwidget); view.setonclickpendingintent(r.id.buttonrecordexpense, pintent); //tell app widget manager perform update ont eh current app widget appmanager.updateappwidget(widgetid, view); } } } its text box button that's supposed 4x1 , beingness added straight app. i've tried rebooting device. stumped on one.
edit:
once run should register widget correct?
android widget
No comments:
Post a Comment