Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Monday, June 9, 2014

Mirror Android screen to PC

Big things come in small packages. This is the exact case with VNC Server. After searching a lot of ways to show my Android screen on PC, I found this to be the only app that worked.

Additionally you will need a VNC viewer app on PC or do it via a browser. Real VNC is a good option.

You can connect via wifi (hotspot from own mobile works) or USB (slow)

The UI is horrible but you can ignore it. One problem is that it might disable your phone keyboard. If so, ho to keyboard selection setting, you'll find a hardware keyboard switch. Turn that off.

Download VNC Server

Friday, May 30, 2014

Waking up device and turning screen on : Android code

For waking a device and turning screen on, you've the following options:

Use PowerManager Wakelock technique.
Or
Use WindowManager LayoutParams Flags.

For going with first option,

problem is the wakelock constructor takes two flags with a OR operator. One level, another Flag.

PowerManager pm = (PowerManager)
getSystemService
(Context.POWER_SERVICE);
wl = pm.newWakeLock
(PowerManager.SCREEN_BRIGHT_
WAKE_LOCK|
PowerManager.ACQUIRE_CAUSES_
WAKEUP, "bbbb");
wl.acquire();

Here, nothing's wrong but , SCREEN_BRIGHT_
WAKE_LOCK and other flags have been deprecated and there's no Level flag that could work with ACQUIRE_CAUSES_
WAKEUP.

It's a good thing since wakelock usage is discouraged.

Second option

FLAG_TURN_SCREEN_ON

LayoutParams Flags are the recommended way, but there's a catch that those flags, once set, work only during a window is created.

That means, you've to set them in your onCreate method before anything else., otherwise they won't work reliably.

So, that invalidates the scope of any condition checking before setting the flags, which could be handled by an extra Activity in control flow. ;) I'll leave it up to here.