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.

inside custom component

Android™ Runtime Development

Reply
Trusted Contributor
Posts: 107
Registered: ‎04-08-2011
My Device: BlackBerry Q10
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

 

 

 

 

Get Speedometer on your phone. http://www.speedometer.mobi
Contributor
Posts: 46
Registered: ‎02-15-2012
My Device: BB Playbook
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);
Trusted Contributor
Posts: 107
Registered: ‎04-08-2011
My Device: BlackBerry Q10
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?

 

 

Get Speedometer on your phone. http://www.speedometer.mobi
Contributor
Posts: 46
Registered: ‎02-15-2012
My Device: BB Playbook
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.

Trusted Contributor
Posts: 107
Registered: ‎04-08-2011
My Device: BlackBerry Q10
My Carrier: Mobilink

Re: Keep Alive Screen in Android java

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

Get Speedometer on your phone. http://www.speedometer.mobi
Contributor
Posts: 19
Registered: ‎02-15-2012
My Device: Playbook
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();

Trusted Contributor
Posts: 107
Registered: ‎04-08-2011
My Device: BlackBerry Q10
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

Get Speedometer on your phone. http://www.speedometer.mobi
Contributor
Posts: 15
Registered: ‎03-16-2012
My Device: Q10, Z10
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

Trusted Contributor
Posts: 107
Registered: ‎04-08-2011
My Device: BlackBerry Q10
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.

 

 

Get Speedometer on your phone. http://www.speedometer.mobi
Developer
Posts: 103
Registered: ‎02-13-2012
My Device: Z10 LE
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

Learn to run and get in shape with Couch 2AnyK Pro, a Built for BlackBerry native Couch to 5K (C25K) app for BlackBerry 10, available in BlackBerry World.