Note that there are some explanatory texts on larger screens.

plurals
  1. POAppwidget keeps reseting background to transparent
    primarykey
    data
    text
    <p>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:</p> <pre><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"))); </code></pre> <p>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.</p> <p>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:</p> <pre><code>/* 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"))); </code></pre> <p>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.</p> <p>How can I detect and/or work around this?</p> <p>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.</p> <p>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.</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