tags:

views:

29

answers:

1

Hi, i'm tryng to create my first widget. To make a experiment i'm tryng to visualize a Toast every update but it doesn't appaire.

This is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.skatephone.smokecounter"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name=".SmokeCounter" >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            <action android:name="com.skatephone.smokecounter.SmokeCounter.ACTION_WIDGET_RECEIVER"/>
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
                   android:resource="@xml/smoke_widget_info" />
    </receiver>
</application>
<uses-sdk android:minSdkVersion="4" />

And in the onUpdate metodh of my AppWidgetProvider class i inserted:

Toast.makeText(context, "onUpdate", Toast.LENGTH_SHORT).show();
appWidgetManager.updateAppWidget(appWidgetIds, views);

It seems that it doesn't update, should do it every 5 seconds!

Any idea?

Thanks Valerio

A: 

I resolved with a Timer:

Timer timer = new Timer();
timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 1, 10000); // Evry 10 seconds

.....

Skatephone