Here is the problem. I work on an Android device with Ice Cream Sandwich and I want to wake up the device when I ping it from a computer by Wifi.
I'm "trying" to use the following piece of code to wake up the device but it seems not to work.
WakeLock lock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
lock.acquire();
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
lock.release();
I'm using a service to wake up the device, but it doesn't seem to work.
You can use android.net.wifi.STATE_CHANGE broadcast event.To achive this you need to register your broadcast inside your manifest file.
This may be help you. http://www.grokkingandroid.com/android-tutorial-broadcastreceiver/