I'm programming a widget. When somebody clicks on the widget Button, the Flashlight is turning on. If you click again on the widget button, the Flashlight is turning off. I wrote a small app, there its works, because i have a surface view in my layout xml file. On my widget xml that is not working.
This is my widget_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<SurfaceView
android:id="@+id/surface"
android:layout_width="1dp"
android:layout_height="1dp" />
<ImageButton
android:id="@+id/button"
android:src="@drawable/off"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scaleType="center"/>
</FrameLayout>
On the developer Page, there is a text:
http://developer.android.com/guide/topics/appwidgets/index.html
A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
GridLayout
And the following widget classes:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper
So my widget button will never work, because i can't use surface view.