Android Open Source - weatherWidget Update Widget Service






From Project

Back to project page weatherWidget.

License

The source code is released under:

GNU General Public License

If you think the Android project weatherWidget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * @file//w w w.  ja v a 2s  . co m
 */
package weather.widget.utils;

import weather.widget.webcall.MyWebservice;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.IBinder;

/**
 * UpdateWidgetService class.\n
 * class which is called on update call of widget.
 * @author Max
 *
 */
public class UpdateWidgetService extends Service {
  
  private UsefullFunctions useFunc = null;   /**< needed to check network connection */

  @Override
  public void onStart(Intent intent, int startId) {
    
    DataBaseHelper dbHelper = new DataBaseHelper(getApplicationContext());
    dbHelper.openDataBase();
    /* Manager fr alle Widgets */
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this
        .getApplicationContext());
    
    /* finde alle Widgets die angelegt wurden */
    int[] allWidgetIds = intent
        .getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
    
    /* aktualisiere Messwerte in der Datenbank durch einen Webcall */
    useFunc = new UsefullFunctions(this);
    
    /* alle Widgets sollen aktualisiert werden */
    useFunc.widgetUpdate(allWidgetIds, getApplicationContext(), appWidgetManager, dbHelper);
    
    if(useFunc.haveNetworkConnection())
      new MyWebservice().execute(this.getApplicationContext(), allWidgetIds, appWidgetManager);

    //dbHelper.close();
    
    stopSelf();
    
    super.onStart(intent, startId);
  }

  @Override
  public IBinder onBind(Intent intent) {
    return null;
  }
}




Java Source Code List

weather.widget.WeatherWidgetActivity.java
weather.widget.graph.WeatherGraphView.java
weather.widget.settings.Settingsmenu.java
weather.widget.utils.DataBaseHelper.java
weather.widget.utils.UpdateWidgetService.java
weather.widget.utils.UsefullFunctions.java
weather.widget.webcall.MyWebservice.java