title: Update android (homescreen) widget from php file
body: <p>I want to make a android widget that it will update from a php file. i found a lot of examples about widgets and a lot of examples of how to retrieve data from php to an activity but i didn't manage to do it.
  i need something like this example (<a href="http://www.vogella.com/tutorials/AndroidWidgets/article.html" rel="nofollow">http://www.vogella.com/tutorials/AndroidWidgets/article.html</a>) but instead of a random number i need to take the number from my php file..   </p>
  
  <p>php file it output a single number that i need to include in my widget (<a href="http://www.angryboards.com/data/larnaca/test.php" rel="nofollow">http://www.angryboards.com/data/larnaca/test.php</a>)</p>
  
  <p>this the WidgetProvider class, but when i am trying to call the AsyncTask in onUpdate() it crashes.    </p>
  
  <pre><code>public class MyWidgetProvider extends AppWidgetProvider {
  
   private TextView textView;
  
  
    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds) {
  
        //call AsyncTask
         String serverURL = "http://www.angryboards.com/data/larnaca/test.php";
           new async().execute(serverURL);
           String txt = textView.getText().toString();
  
  
      // Get all ids
      ComponentName thisWidget = new ComponentName(context,
          MyWidgetProvider.class);
      int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
      for (int widgetId : allWidgetIds) {
  
  
  
  
  
  
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
            R.layout.widget_layout);
  
        // Set the text
        remoteViews.setTextViewText(R.id.update, txt);
  
        // Register an onClickListener
        Intent intent = new Intent(context, MyWidgetProvider.class);
  
        intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
  
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
            0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        remoteViews.setOnClickPendingIntent(R.id.update, pendingIntent);
        appWidgetManager.updateAppWidget(widgetId, remoteViews);
      }
    }
  
   private class async extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
        String response = "";
        for (String url : urls) {
          DefaultHttpClient client = new DefaultHttpClient();
          HttpGet httpGet = new HttpGet(url);
          try {
            HttpResponse execute = client.execute(httpGet);
            InputStream content = execute.getEntity().getContent();
  
  
            BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
            String s = "";
            while ((s = buffer.readLine()) != null) {
              response += s;
            }
  
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
  
        return response;
      }
  
      @Override
      protected void onPostExecute(String result) {
        textView.setText(result);
  
  
  
  
      }
    }
  
  } 
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.tasos.widgettest"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
  
       /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.tasos.widgettest.MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
   &lt;receiver
     android:icon="@drawable/logo"
     android:label="Example Widget"
     android:name="MyWidgetProvider" &gt;
     &lt;intent-filter &gt;
          &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt;
     &lt;/intent-filter&gt;
  
     &lt;meta-data
        android:name="android.appwidget.provider"
        android:resource="@xml/widget_info" /&gt;
  &lt;/receiver&gt; 
  
  &lt;/application&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>widget_info.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;appwidget-provider 
    xmlns:android="http://schemas.android.com/apk/res/android"
  android:initialLayout="@layout/widget_layout"
  android:minHeight="72dp"
  android:minWidth="300dp"
  android:updatePeriodMillis="3000" &gt;
  
  &lt;/appwidget-provider&gt; 
  </code></pre>
  
  <p>and in layout i have a textview (android:id="@+id/update")
  Thanks</p>