Saturday, 6 December 2014

Android Error Loading Widget



Getting a 'Problem loading widget' error on my application.


This is my first time working with android widgets, but I have several normal applications on the market, so I'm looking for some troubleshooting here. When long-pressing on my home screen to find my widget to place, the icon shows up fine. When I grab the widget to place on my home screen, is where the widget now displays 'problem loading widget'.


I am setting my widget to be a minimum of 1x1 cells (72dp by 72dp). Could this be because my source image (turnup_button.png) is 400x400 pixels? Thanks guys, codes posted below.


Layout XML



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/turnup_button" />
</RelativeLayout>


Widget XML



<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://ift.tt/nIICcg"
android:minWidth="72dp"
android:minHeight="72dp"
android:updatePeriodMillis="0"
android:initialLayout="@layout/main">
</appwidget-provider>


Android manifest



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="creativecoders.turnupbutton" >

<application android:icon="@drawable/turnup_button" android:label="@string/app_name" >
<receiver android:name="Main" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="creativecoders.turnupbutton.ACTION_WIDGET_RECEIVER" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget" />
</receiver>
</application>
</manifest>

No comments:

Post a Comment