0

Currently I am working on a mobile based application using Flex 4 and action script 3. Normally for locking android phones, we need to press the lock button, but I want to lock the android phone by application.

Is there any API available for this? I need to lock the phone by running the application, which is created using Flex 4 and action script 3. Please give me some idea for this..

Gunther Struyf
  • 11,158
  • 2
  • 34
  • 58
praba
  • 1,074
  • 3
  • 17
  • 38

2 Answers2

0

Using Flex 4 is little difficult. better you can try with native android application. There are some options are available, like

KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); 
KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); 
lock.reenableKeyguard();

and another way is android.os.PowerManager

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
wl.acquire();
//and use 
wl.release();

The detail description about PowerManager you can find from here.

Rob
  • 4,927
  • 12
  • 49
  • 54
Rathakrishnan Ramasamy
  • 1,612
  • 2
  • 25
  • 46
-1

I am not sure whether locking the device pro grammatically is still possible with Android, but you may follow this SO discussion for the latest.

AIR does not provide API to lock a mobile device, because such capability is not universally available on all mobile/desktop platforms. AIR's design philosophy is to keep its default SDK features to be available to all platforms, so developers don't have to think of platforms' discrepancies.

The latest AIR provides the means to extend platform-specific capability through Native Extension (ANE). You can check variety of extensions over numerous sites such as this one.

That said, if Android natively provides locking capability, you are in good luck. Even if such ANE is not available, I am sure you can easily get one developed.

Community
  • 1
  • 1
Tianzhen Lin
  • 2,404
  • 1
  • 19
  • 19