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 6787705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:23:52+00:00 2026-05-26T17:23:52+00:00

Hi all I want to make a battery widget in android with animation. I

  • 0

Hi all I want to make a battery widget in android with animation. I think I will be able to animate but I want to know that how can I get the battery status again and again? Will it be OK to do it through thread? Or something else is required. Here is the simple code for animation. Please explain how will I get the data from battery again and again all the time.I know the functions but I don’t know the mechanism to use them.

    public class HelloWidget  extends AppWidgetProvider{

    RemoteViews remoteViews;
    AppWidgetManager appWidgetManager;
    ComponentName thisWidget;
    ImageView img;
    Bitmap icon, icon1;
    int counter = 0;

    @Override
    public void onUpdate(Context context, final AppWidgetManager appWidgetManager,
    int[] appWidgetIds) {



        this.appWidgetManager = appWidgetManager;
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
        thisWidget = new ComponentName(context, HelloWidget.class);
        remoteViews.setImageViewResource(R.id.imgv, R.drawable.icon2);
        appWidgetManager.updateAppWidget(thisWidget, remoteViews);


        ( new Thread() 
        {

            public void run()
            {

                while(true)
                {
                    if(counter%15>=0 && counter%15 <=7)
                    {
                        remoteViews.setImageViewResource(R.id.imgv, R.drawable.icon2);
                    }
                    else
                    {
                        remoteViews.setImageViewResource(R.id.imgv, R.drawable.icon);
                    }
                    appWidgetManager.updateAppWidget(thisWidget, remoteViews);
                    counter++;
                }

             }

        }

            ).start();




}
  • 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-26T17:23:53+00:00Added an answer on May 26, 2026 at 5:23 pm

    Register broadcast receiver for battery events and don’t query every time.

    IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    mContext.registerReceiver(batteryLevelReceiver, batteryLevelFilter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make sure that all 3 conditions result in the same answer
I'm having some problems using RemoteViews. Simply want to make a widget that shows
I want to make a Style that can be applied to a TextBlock to
I want to make the background of a QDialog transparent so that I can
I want to make a page dynamically in android using eclipse... I have all
I am working on an Android app that I want to run on all
I want to make a battery meter for my computers, which all work on
Hi All I want to make some animation using c#.Animation should include water falling
I want to make an android application that when it reaches a predefined GPS
I want to make a very generic pure virtual class i_BIS_Data that will be

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.