Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Android™ Runtime Development

Reply
Regular Contributor
basitj
Posts: 80
Registered: ‎04-08-2011
My Carrier: Mobilink

Keep Alive Screen in Android java

Hey Guys, I want to make an app that keeps the screen of PlayBook always on.

 

In my Android code I have done following:

 

Called setKeepScreenOn(true); on one of my images

 

Added permission: android.permission.KEEP_SCREEN_ON

 

This has no effect on the screen.

 

The screen settings of Playbook are still effective and BackLight Time-out and Stand-By Time out work as they are working in the other apps. Can somebody help?

 

Please note that the Android devices are working fine, I can get the KEEP_SCREEN_ON working on Android and the phones and tabs running on android will drain the battery but will not go off.

 

Please advise.

 

 

Thanks

 

 

 

 

Please use plain text.
Contributor
mattdonders
Posts: 46
Registered: ‎02-15-2012
My Carrier: Verizon Wireless

Re: Keep Alive Screen in Android java

Double checked the documentation and it doesn't state that this feature is not supported when porting Android to Playbook.

I'd try this to keep the screen on in Android -- this is what I've used before it its definitely a simpler way.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Please use plain text.
Regular Contributor
basitj
Posts: 80
Registered: ‎04-08-2011
My Carrier: Mobilink

Re: Keep Alive Screen in Android java

Thanks for your tip, but that didn't work as well. Screen goes off after 30 seconds (that's what I've set in settings on OS)

 

Any other ideas?

 

 

Please use plain text.
Contributor
mattdonders
Posts: 46
Registered: ‎02-15-2012
My Carrier: Verizon Wireless

Re: Keep Alive Screen in Android java


basitj wrote:

Thanks for your tip, but that didn't work as well. Screen goes off after 30 seconds (that's what I've set in settings on OS)

 

Any other ideas?

 

 


Not off the top of my head -- if I think of anything I will post back here.

 

Hopefully someone can help you before then.

Please use plain text.
Regular Contributor
basitj
Posts: 80
Registered: ‎04-08-2011
My Carrier: Mobilink

Re: Keep Alive Screen in Android java

And yes, your code does work on Android Devices, fails on Playbook. :smileysad:

Please use plain text.
Contributor
marklogan
Posts: 19
Registered: ‎02-15-2012
My Carrier: Rogers

Re: Keep Alive Screen in Android java

Haven't tried on an actual playbook but at least my apps got approved so the functionality should be there - check for other types of wake locks to get the right one for you:

 

AndroidManifest.xml

<uses-permission android:name="android.permission.WAKE_LOCK"

 

Variable:

WakeLock mWakeLock;


In OnCreate:

PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK /*SCREEN_DIM_WAKE_LOCK*/, "RunGame");

 

In OnPause:

mWakeLock.release();   

 

In OnResume:

mWakeLock.acquire();

Please use plain text.
Regular Contributor
basitj
Posts: 80
Registered: ‎04-08-2011
My Carrier: Mobilink

Re: Keep Alive Screen in Android java

Thanks for the help @marklogan but that did not help.

 

Can you please send me a link to the app so that i can try it out if ur app keeps a wake lock on real device or not?

 

Thanks

Please use plain text.
Contributor
alexvas
Posts: 12
Registered: ‎03-16-2012
My Carrier: n/a

Re: Keep Alive Screen in Android java

I've double checked. This is a BB Playbook issue in their Android implementation. I've created a bug report. Vote for that if you want WakeLock to be implemented.

 

Android: PowerManager.WakeLock is not working

https://www.blackberry.com/jira/browse/TABLET-531

Please use plain text.
Regular Contributor
basitj
Posts: 80
Registered: ‎04-08-2011
My Carrier: Mobilink

Re: Keep Alive Screen in Android java

Thanks for the response, I've voted for it already. I hope more fellas vote for it too.

 

 

Please use plain text.
Developer
nonesuchnick
Posts: 78
Registered: ‎02-13-2012
My Carrier: Rogers

Re: Keep Alive Screen in Android java

This issue affects my Android app as well, and I've also voted on it and added my comments.  Thanks for creating the bug report!  I'm glad there was already a forum thread and bug for this, otherwise I would have been banging my head against the wall trying to get this to work!  This should definitely be implemented! I really don't see how any Android apps that display changing info on the screen without requiring user interaction can correctly function otherwise!  Wouldn't this even affect video playback in android apps?  I can't believe it's not implemented.

 

Nick

Please use plain text.