[Q] How can I change the layout for a widget in runtime?

220 posts
Thanks Meter: 6
By saman0suke1, Senior Member on 26th February 2014, 06:19 PM
Post Reply Subscribe to Thread Email Thread
Hi, I have a widget that I want to use as lockscreen as well ( since android 4.2+ allows it), so I need to change the layout when the widget is on the lock screen and when is on the regular screen, how can i do it? I tried to use the Intent ACTION_USER_PRESENT but my BroadcastReceiver never gets it. I have it defined in the manifest as well:

PHP Code:
android:label="widgetBroadcastReceiver" >
action android:name="android.intent.action.USER_PRESENT" >

android:resource="@xml/demo_widget_provider" />

public class 
MyWidgetIntentReceiver extends BroadcastReceiver{

void onReceive(Context contextIntent intent) {

Is there any other way that I can check when the widget is in the lock screen or not? I tried this guide as well:

But how do I check that every time that I lock/unlock the screen?


EDIT: I ended up using Intent.ACTION_USER_PRESENT to check when the screen is unlocked, Thanks!
Last edited by saman0suke1; 28th February 2014 at 08:22 PM.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes