Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:31:10+00:00 2026-06-13T18:31:10+00:00

I have a very big problem guys. I have an app which fetches and

  • 0

I have a very big problem guys. I have an app which fetches and parses the RSS feed from a blog, but I don’t know how to put the results into my widget.

Here is the RSSListActivity which shows the rss feed correctly in it’s own activity:

@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        RSSItem data = itemlist.get(position);

        Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(data.link));

        startActivity(intent);
    }

    private void retrieveRSSFeed(String urlToRssFeed,ArrayList<RSSItem> list)
    {
        try
        {
           URL url = new URL(urlToRssFeed);
           SAXParserFactory factory = SAXParserFactory.newInstance();
           SAXParser parser = factory.newSAXParser();
           XMLReader xmlreader = parser.getXMLReader();
           RSSParser theRssHandler = new RSSParser(list);

           xmlreader.setContentHandler(theRssHandler);

           InputSource is = new InputSource(url.openStream());

           xmlreader.parse(is);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    private class RetrieveRSSFeeds extends AsyncTask<Void, Void, Void>
    {
        private ProgressDialog progress = null;

        @Override
        protected Void doInBackground(Void... params) {
            retrieveRSSFeed("http://blog.qubiz.com/index.php/feed",itemlist);

            rssadaptor = new RSSListAdaptor(RSSListActivity.this, R.layout.rssitemview,itemlist);

            return null;
        }

        @Override
        protected void onCancelled() {
            super.onCancelled();
        }

        @Override
        protected void onPreExecute() {
            progress = ProgressDialog.show(
                    RSSListActivity.this, null, "Loading RSS Feed... Please wait");

            super.onPreExecute();
        }

        @Override
        protected void onPostExecute(Void result) {
            setListAdapter(rssadaptor);

            progress.dismiss();

            super.onPostExecute(result);
        }

        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);
        }
    }

    private class RSSListAdaptor extends ArrayAdapter<RSSItem>{
        private List<RSSItem> objects = null;

        public RSSListAdaptor(Context context, int textviewid, List<RSSItem> objects) {
            super(context, textviewid, objects);

            this.objects = objects;
        }

        @Override
        public int getCount() {
            return ((null != objects) ? objects.size() : 0);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public RSSItem getItem(int position) {
            return ((null != objects) ? objects.get(position) : null);
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;

            if(null == view)
            {
                LayoutInflater vi = (LayoutInflater)RSSListActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = vi.inflate(R.layout.rssitemview, null);
            }

            RSSItem data = objects.get(position);

            if(null != data)
            {
                TextView title = (TextView)view.findViewById(R.id.txtTitle);
                TextView date = (TextView)view.findViewById(R.id.txtDate);
                TextView description = (TextView)view.findViewById(R.id.txtDescription);

                title.setText(data.title);
                date.setText("on " + data.date);
                String prova = android.text.Html.fromHtml(data.description).toString();
                //description.setText(data.description);
                description.setText(prova);
            }

            return view;
        }
    }

    public boolean onCreateOptionsMenu(Menu menu)
    {
        menu.add(1,1,0,"About");
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item)
    {
        switch(item.getItemId())
            {
        case 1:

            AlertDialog.Builder conferma_canc = new AlertDialog.Builder(this);
            conferma_canc.setTitle("About");
            conferma_canc.setMessage("Copyright © 2012 Qubiz. All rights reserved. Android version designed and developed by Csosz Gergo Levente, Qubiz Romania.");
            conferma_canc.setPositiveButton("OK", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
              }
            });
            AlertDialog alert = conferma_canc.create();
            alert.show();
            return true;
            }
        return false;           
    } 

And here it is my RSS parser which also works as it should:

public class RSSParser extends DefaultHandler {
    private final static String TAG_ITEM = "item";
    private final static String[] xmltags = { "title", "link", "pubDate", "description" };

    private RSSItem currentitem = null;
    private ArrayList<RSSItem> itemarray = null;
    private int currentindex = -1;
    private boolean isParsing = false;
    private StringBuilder builder = new StringBuilder();

    public RSSParser(ArrayList<RSSItem> itemarray) {
        super();

        this.itemarray = itemarray;
    }

    @Override
    public void characters(char[] ch, int start, int length) throws SAXException {
        super.characters(ch, start, length);

        if(isParsing && -1 != currentindex && null != builder)
        {
            builder.append(ch,start,length);
        }
    }

    @Override
    public void startElement(String uri, String localName, String qName,Attributes attributes) throws SAXException {
        super.startElement(uri, localName, qName, attributes);

        if(localName.equalsIgnoreCase(TAG_ITEM))
        {
            currentitem = new RSSItem();
            currentindex = -1;
            isParsing = true;

            itemarray.add(currentitem);
        }
        else
        {
            currentindex = itemIndexFromString(localName);

            builder = null;

            if(-1 != currentindex)
                builder = new StringBuilder();
        }
    }

    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
        super.endElement(uri, localName, qName);

        if(localName.equalsIgnoreCase(TAG_ITEM))
        {
            isParsing = false;
        }
        else if(currentindex != -1)
        {
            if(isParsing)
            {
                switch(currentindex)
                {
                    case 0: currentitem.title = builder.toString();         break; 
                    case 1: currentitem.link = builder.toString();          break;
                    case 2: currentitem.date = builder.toString();          break;
                    case 3: currentitem.description= builder.toString();    break;
                }
            }
        }
    }

    private int itemIndexFromString(String tagname){
        int itemindex = -1;

        for(int index= 0; index<xmltags.length; ++index)
        {
            if(tagname.equalsIgnoreCase(xmltags[index]))
            {
                itemindex = index;

                break;
            }
        }

        return itemindex;
    }
}

My ExampleAppWidgetProvider.java where is a sample clock widget code which I want to replace to show my rss feed.

public class ExampleAppWidgetProvider extends AppWidgetProvider {
    static DateFormat df = new SimpleDateFormat("hh:mm:ss");
    private static final String LOG_TAG = "ExampleWidget";

    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
        final int N = appWidgetIds.length;
        Log.i("ExampleWidget", "Updating widgets " + Arrays.asList(appWidgetIds));
        for (int i = 0; i < N; i++) {
            int appWidgetId = appWidgetIds[i];
            Intent intent = new Intent(context, ExampleAppWidgetProvider.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget1);
            views.setOnClickPendingIntent(R.id.button, pendingIntent);
            views.setTextViewText(R.id.widget1label, df.format(new Date()));

            appWidgetManager.updateAppWidget(appWidgetId, views);
        }
    }

    private PendingIntent createClockTickIntent(Context context) {
        Intent intent = new Intent(CLOCK_WIDGET_UPDATE);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        return pendingIntent;
    }

    @Override
    public void onEnabled(Context context) {
        super.onEnabled(context);
        Log.d(LOG_TAG, "Widget Provider enabled.  Starting timer to update widget every second");
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.SECOND, 1);
        alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(),1000, createClockTickIntent(context));
    }

    @Override
    public void onDisabled(Context context) {
        super.onDisabled(context);
        Log.d(LOG_TAG, "Widget Provider disabled. Turning off timer");
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.cancel(createClockTickIntent(context));
    }

    public static String CLOCK_WIDGET_UPDATE = "com.eightbitcloud.example.widget.8BITCLOCK_WIDGET_UPDATE";

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
        Log.d(LOG_TAG, "Received intent " + intent);
        if (CLOCK_WIDGET_UPDATE.equals(intent.getAction())) {
            Log.d(LOG_TAG, "Clock update");
            ComponentName thisAppWidget = new ComponentName(context.getPackageName(), getClass().getName());
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            int ids[] = appWidgetManager.getAppWidgetIds(thisAppWidget);
            for (int appWidgetID : ids) {updateAppWidget(context, appWidgetManager, appWidgetID);
            }
        }
    }

    public static void updateAppWidget(Context context,AppWidgetManager appWidgetManager, int appWidgetId) {
        String currentTime = df.format(new Date());
        RemoteViews updateViews = new RemoteViews(context.getPackageName(),R.layout.widget1);
        updateViews.setTextViewText(R.id.widget1label, currentTime);
        appWidgetManager.updateAppWidget(appWidgetId, updateViews);
    }

}

Could any1 provide me a solution?
My aim is to: replace the widget’s clock java code with my rss feed reader.
So I want to show the last rss item in the widget which is parsed by the rss parser. How can I do that?
Please provide code too, not only a few ideas, I am kinda new to android development.
Thank you for help in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:31:12+00:00Added an answer on June 13, 2026 at 6:31 pm

    (Assuming you got RSS retrieval and parsing correctly)
    You just have to change some text in widget:

        AppWidgetManager manager = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.name_of_your_widget_layout);
        // set text of some view
        views.setTextViewText(R.id.widget_amount_cameras, amountCameras);
        // and of another view
        views.setTextViewText(R.id.widget_location, locationCity);
        // ... and yet another view
        views.setTextViewText(R.id.locationStatus, locationStatus);
    
       // get IDs of widgets ,  there could be more than  one
        final int[] appWidgetIds = manager.getAppWidgetIds(new ComponentName(YOurWidgetProviderClass.class.getPackage().getName(), YOurWidgetProviderClass.class.getName()));
    
        // update all hte instances
        manager.updateAppWidget(appWidgetIds, views);
    

    You can change only some attributes of your widgets ( due to security constraints ) – See Javadoc of RemoteViews for further explanations

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very big problem in my SQL query and i don't know how
I have imported a very big java project from CVS . The problem is
I have a very big problem. I am making a CRM (Costumer Relationship Management)
I have got very big problem because I would like to get more information
I have a big problem with very simple code. I need to get a
So, this is my problem: I have this very big image, and I want
I have a very big problem and can't seem to find anybody else on
my problem is with Powershell. I have a very big Folder. Insider are about
i have a very big array which is shared among many functions in many
I have a very big problem with my website. I have a form, more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.