title: Android Widget: doesn't update after certain period of time
body: <p>Guys, I developed an android widget with an imageview and a single textview. It works fine, but after some updates the messages from my external file with the strings (quotes) doesn't update it. It just shows the image without any quote (message). Why is this happening?
  He's my entire code. I'm a newbie.</p>
  
  <p>Main.java</p>
  
  <pre><code>import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  
  public class Main extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  }
  
  
  }
  </code></pre>
  
  <p>UpdateWidgetService.java</p>
  
  <pre><code>public class UpdateWidgetService extends Service {
  private static final String TAG = CopyOfUpdateWidgetService.class.getSimpleName();
  
  @Override
  public IBinder onBind(Intent arg0) {
      return null;
  }
  
  @Override
  public void onStart(Intent intent, int startId) {
      super.onStart(intent, startId);
  
      Log.d(TAG, "onStart started");
  
      // Create some random data
      Random random = new Random();
  
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this.getApplicationContext());
  
      int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
  
      if (appWidgetIds.length &gt; 0) {
  
          for (int widgetId : appWidgetIds) {
              List&lt;String&gt; qList = getListFromTxtFile("quotes.txt");
              int nextInt = random.nextInt(qList.size());
  
              RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget);
              remoteViews.setTextViewText(R.id.widget_textview, qList.get(nextInt));
              appWidgetManager.updateAppWidget(widgetId, remoteViews);
          }
          stopSelf();
      }
      super.onStart(intent, startId);
  }
  
  public List&lt;String&gt; getListFromTxtFile(String txtFileName){
  
  //  File sdcard = Environment.getExternalStorageDirectory();
  // Get the text file
  // File file = new File(sdcard,txtFileName);
  
  AssetManager am = this.getAssets();
  
  List&lt;String&gt; qList = new ArrayList&lt;String&gt;();
  
  //Read text from file
  
  try {
      InputStream is = am.open("quotes.txt");
            //BufferedReader br = new BufferedReader(new FileReader(file));
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      String line;
  
       // get data in text file line by line
      while ((line = br.readLine()) != null) {
  
          Log.d("line",line);
  
         qList.add(line);
      }
  }
  catch (IOException e) {
      //You'll need to add proper error handling here
  
      {Log.d("Error","There are an error");}
  }
  return qList;
  
  }
  
  }
  </code></pre>
  
  <p>WidgetQuotes.Java</p>
  
  <pre><code>public class WidgetQuotes extends AppWidgetProvider {
  
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      super.onUpdate(context, appWidgetManager, appWidgetIds);
  
      // Build the intent to call the service
      RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
      Intent intent = new Intent(context.getApplicationContext(), UpdateWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
  
      // To react to a click we have to use a pending intent as the
      // onClickListener is
      // excecuted by the homescreen application
      PendingIntent pendingIntent = PendingIntent.getService(
              context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
      remoteViews.setOnClickPendingIntent(R.id.widget_textview, pendingIntent);
  
      // Finally update all widgets with the information about the click
      // listener
      appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
  
      // Update the widgets via the service
      context.startService(intent);
  }
  
  public void onDeleted(Context context, int[] appWidgetIds) {
      //  Toast.makeText(context, "onDelete", Toast.LENGTH_SHORT).show();
          super.onDeleted(context, appWidgetIds);
      }
  
  @Override
  public void onReceive(Context context, Intent intent) {
      super.onReceive(context, intent);
  }
  }
  </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.esmeralda"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
      &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="15" /&gt;
      &lt;supports-screens android:smallScreens="true" android:largeScreens="true"    android:normalScreens="true"/&gt;
  
     &lt;application android:icon="@drawable/icone" android:label="@string/app_name"&gt;
  
      &lt;receiver android:name="com.esmeralda.WidgetQuotes" android:label="@string/app_name"&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_quotes_info" /&gt;
      &lt;/receiver&gt;
  
      &lt;service android:name="com.esmeralda.UpdateWidgetService"&gt;&lt;/service&gt;
  &lt;activity
  android:name="com.esmeralda.Main"
  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;action android:name="com.esmeralda.ACTION_WIDGET_CONFIGURE"/&gt;
  &lt;/intent-filter&gt;
  &lt;/activity&gt;
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>widget_quotes_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:minWidth="294dp"
  android:minHeight="250dp"
  android:updatePeriodMillis="1800020"
  android:initialLayout="@layout/widget" /&gt;
  </code></pre>