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

  • SEARCH
  • Home
  • 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 829167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:50:22+00:00 2026-05-15T03:50:22+00:00

I am currently learning about widgets in Android. I want to create a WIFI

  • 0

I am currently learning about widgets in Android.

I want to create a WIFI widget that will display the SSID, the RSSI (Signal) level.

But I also want to be able to send it data from a service I am running that calculates the Quality of Sound over wifi.

Here is what I have after some reading and a quick tutorial:


public class WlanWidget extends AppWidgetProvider{

RemoteViews remoteViews;
AppWidgetManager appWidgetManager;
ComponentName thisWidget;
WifiManager wifiManager;

public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds) {
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new WlanTimer(context, appWidgetManager), 1, 10000);

}


private class WlanTimer extends TimerTask{

        RemoteViews remoteViews;
        AppWidgetManager appWidgetManager;
        ComponentName thisWidget;


public WlanTimer(Context context, AppWidgetManager appWidgetManager) {

        this.appWidgetManager = appWidgetManager;
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
        thisWidget = new ComponentName(context, WlanWidget.class);
        wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);


}

@Override
public void run() {

        remoteViews.setTextViewText(R.id.widget_textview,
        wifiManager.getConnectionInfo().getSSID());
        appWidgetManager.updateAppWidget(thisWidget, remoteViews);
}

}

The above seems to work ok, it updates the SSID on the widget every 10 seconds.

However what is the most efficent way to get the information from my service that will be already running to update periodically on my widget?

Also is there a better approach to updating the the widget rather than using a timer and timertask? (Avoid polling)

UPDATE

As per Karan’s suggestion I have added the following code in my Service:


RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
ComponentName thisWidget = new ComponentName( context, WlanWidget.class );
remoteViews.setTextViewText(R.id.widget_QCLevel, " " + qcPercentage);
AppWidgetManager.getInstance( context ).updateAppWidget( thisWidget, remoteViews );

This gets run everytime the RSSI level changes but it still never updates the TextView on my widget, any ideas why?

EDIT

Got it working, thanks Karan

  • 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-05-15T03:50:23+00:00Added an answer on May 15, 2026 at 3:50 am

    You can use the following code to update the data of widget :

    ComponentName thisWidget = new ComponentName( getContext(), <ProviderClass> );
    AppWidgetManager.getInstance( getContext() ).updateAppWidget( thisWidget, rempoteViews );
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm learning about neural networks and I'm trying to create an application that
I am currently learning about these maps. Now I would like to create a
I currently learning about scrum and want to learn from experienced professionals in the
I am currently learning jQuery, and I am curious about something. For functions that
I am currently learning about basic networking in java. I have been playing around
I'm currently learning about pointers in my C++ book (Programming: Principles and Practice using
I'm currently learning about binary trees and binary search trees, and one of the
I'm currently learning a bit more about Linq-To-Entities - particularly at the moment about
I am currently learning C# and LINQ. I have lots of questions about them.
Happy easters, everyone. I am currently learning topological sort and having a question about

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.