Android widget not visible on Lenovo K5 – Solved

I’ve created Android Widget for controlling ESP8266 relay the last week.

widget-android

The only problem was that the widget was not visible on Lenovo K5.

I was searching for the root cause using method: “Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth.”

I grabbed several other repositories with widgets from Github. Widgets from other projects were working.

To keep long story short. Here is the configuration when widget does not appear:

2016-11-12-android-studio-nothing

Here is the configuration when widget properly appears:

2016-11-12-android-studio-default

Can you spot the difference?

It is very simple. Large number of Android devices displays widget just after installation even when using the first configuration. The problem with Lenovo K5 is that it does not register widget just after installation via adb. You need to launch MainActivity and only after that UI subsystem displays the widget.

Original code from Obaro’s repo is without MainActivity. I took inspiration from Udacity’s Android widget. After I’ve added MainActivity and several other small files into the project the widget appeared even on Lenovo K5.

You can find updated version at GitHub/LampWidget. Thanks to Adusak for a hint about MainActivity.

12. November 2016 at 15:44 - IoT (Tags: , , ). Both comments and pings are currently closed.

Comments are closed.