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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:58:02+00:00 2026-05-31T18:58:02+00:00

I created functionality in an appwidget that allows a user to change the background

  • 0

I created functionality in an appwidget that allows a user to change the background from transparent to semi-transparent. The default is set to transparent in the xml. When the user changes the background preference the setting is saved and the background is updated using below code:

public static Bitmap setBackground (int bgcolor)
{
  {
    Bitmap.Config config=Bitmap.Config.ARGB_8888; 
    Bitmap bitmap=Bitmap.createBitmap(2, 2, config);
    Canvas canvas=new Canvas(bitmap); 
    canvas.drawColor(bgcolor);
    return bitmap;
  }
}

/* set background */
if (ExampleWidgetProvider.background==1)
  views.setImageViewBitmap(R.id.bgcolor, setBackground(Color.parseColor("#aaaaaaaa")));
else
  views.setImageViewBitmap(R.id.bgcolor, setBackground(Color.parseColor("#00000000")));

One user reports that the background is changed back to transparent when he has set it to be semi-transparent. This may happen seemingly random within a few minutes an hour or half a day.

I realised this is a problem with the background and not some kind of preference resetting because I sent the user a version of the appwidget that will always change the background to semi-transparent, i.e. using:

/* set background */
if (ExampleWidgetProvider.background==1)
  views.setImageViewBitmap(R.id.bgcolor, setBackground(Color.parseColor("#aaaaaaaa")));
else
  views.setImageViewBitmap(R.id.bgcolor, setBackground(Color.parseColor("#aaaaaaaa")));

But interestingly that didn’t fix it.
Since the default in the xml is set to transparent I am suspecting the app somehow is either restarted or redrawn and the default layout is being used.

How can I detect and/or work around this?

Update: User (as expected) confirmed fix which permanently changes background colour in xml to semi transparent is working. Which means the system is resetting the background for some unknown reason.

The user uses an LG PG 970 V. 2.2.2 and for what it’s worth he is using “Juice Defender Ultimate” and has it configured to not connect to the internet during the night. My appwidget does connect to the internet at regular intervals.

  • 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-31T18:58:03+00:00Added an answer on May 31, 2026 at 6:58 pm

    Well, I actually found a way to reproduce it. I have an LG with a slide out keyboard, which rotates the home screen when you slide out the keyboard. Once it does that the semi transparent background disappears. It looks like I have to detect some kind of redraw event.

    I found a work around, or solution, not entirely sure. Either way it solves the problem, at least when I test it with the above mentioned method of reproducing.

    I implement a service that I keep running permanently, which overrides onConfigurationChanged() method.

    For ideas see:

    • Button click lost on widget when screen is rotated
    • http://developer.android.com/reference/android/content/Intent.html#ACTION_CONFIGURATION_CHANGED

    you can not receive this through components declared in manifests

    This provides solutions for activities, but I am not sure yet how to use something like that in appwidgets, if at all possible:

    • Saving Android Activity state using Save Instance State

    Code sample, this service is started in the AppWidgetProvider class in the onEnabled() method. So it’s only run once regardless of how many instances of your appwidget are running and should ideally be able to deal with any instance.

    public class ExampleConfigChangeService extends Service
    {
      @Override
      public void onCreate()
      {
        super.onCreate();
        /* whatever code you need here */
      }

    @Override
    public void onStart(Intent intent, int startId)
    {
    super.onStart(intent, startId);
    /* whatever code you need here */
    }

    /* you need this or it will not compile **/
    @Override
    public IBinder onBind(Intent intent)
    {
    /* We don't need to bind to this service */
    return null;
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig)
    {
    /*
    * this is the code that will run whenever an ACTION_CONFIGURATION_CHANGED happens
    * do whatever needs to be done, such as re-reading preferences,
    * resetting background to user's preferred setting etc.
    */
    }
    }

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

Sidebar

Related Questions

I have created a generic behavior that encapsulates tcp/ip functionality. All the user of
I have created a nested list with drag/drop functionality. My issue is that I
Background: I'm trying to create a pure D language implementation of functionality that's roughly
I have created a page that has similar functionality to that of the DiggBar
Is it possible to add dict functionality to user created classes? ie: class Foo(object):
I am building an application that has the functionality like 3 tabs created using
I've created quite a few user controls to encapsulate GUI functionality used in multiple
I have created an Html 5 page that provides important server-side functionality. Unfortunately, it
With functionality from the RODBC package, I have successfully created an ODBC but receive
I've created a MapObject that is handling my Google Mapping functionality. The object collects

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.