Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing an array in home screen widget
    primarykey
    data
    text
    <p>I am trying to show some news in the home screen and I have this code. I want to show every new after lets say 5 seconds from the array.</p> <pre><code>public class PointlessWidget extends AppWidgetProvider{ static final String DATA_TITLE = "T"; static final String DATA_LINK = "L"; static LinkedList&lt;HashMap&lt;String, String&gt;&gt; data1; static String feedUrl; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // TODO Auto-generated method stub super.onUpdate(context, appWidgetManager, appWidgetIds); RemoteViews v = new RemoteViews(context.getPackageName(), R.layout.widget_layout); feedUrl = "http://www.blabla.com"; XMLParser parser = new XMLParser(feedUrl); data1 = (LinkedList&lt;HashMap&lt;String, String&gt;&gt;)parser.parse(); Iterator&lt;HashMap&lt;String, String&gt;&gt; itr = data1.iterator(); Object element; HashMap&lt;String, String&gt; entry; String Temp_URL=null,Temp_TITULO=null,Actual_URL,Actual_TITULO,Anterior_URL = null,Anterior_TITULO,Sigiente_URL,Sigiente_TITULO; while (itr.hasNext()) { element = itr.next(); entry = (HashMap&lt;String, String&gt;) element; mierda = entry.get("T"); try { Thread.sleep(5000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } v.setTextViewText(R.id.word_title, mierda); AppWidgetManager manager = AppWidgetManager.getInstance(context); manager.updateAppWidget(appWidgetIds, v); Log.i("***Selected Tab", "Im currently in tab with index::" + mierda); } </code></pre> <p>The problem is I manage to show one or two elements and then it stops because it says something like object not locked by thread before wait().</p> <p>How can I implement this? Thank you a lot</p> <hr> <p>I implemented service but still throws ANR error.</p> <pre><code> @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // To prevent any ANR timeouts, we perform the update in a service context.startService(new Intent(context, UpdateService.class)); } public static class UpdateService extends Service { @Override public void onStart(Intent intent, int startId) { // Build the widget update for today RemoteViews v = new RemoteViews(this.getPackageName(), R.layout.widget_layout); feedUrl = "http://www.blabla.com"; XMLParser parser = new XMLParser(feedUrl); data1 = (LinkedList&lt;HashMap&lt;String, String&gt;&gt;)parser.parse(); int size = data1.size(); Iterator&lt;HashMap&lt;String, String&gt;&gt; itr = data1.iterator(); Object element; HashMap&lt;String, String&gt; entry; String Temp_URL=null,Temp_TITULO=null,Actual_URL,Actual_TITULO,Anterior_URL = null,Anterior_TITULO,Sigiente_URL,Sigiente_TITULO; while (itr.hasNext()) { element = itr.next(); entry = (HashMap&lt;String, String&gt;) element; mierda = entry.get("T"); try { Thread.sleep(5000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } v.setTextViewText(R.id.word_title, mierda); ComponentName thisWidget = new ComponentName(this, PointlessWidget.class); AppWidgetManager manager = AppWidgetManager.getInstance(this); manager.updateAppWidget(thisWidget, v); Log.i("***Selected Tab", "Im currently in tab with index::" + mierda); } } </code></pre> <p>How can I fix this? Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload