I\'m trying to create an application that allow the user to lock his android device with a password from a website. So i must find a method to lock the device programmatical
The selected answer is right on the money.
Having said that, if you are interested, here is some sample code you can take a look at:
A PolicyManager that performs remote Locking and remote wiping: http://openmobster.googlecode.com/svn/trunk/cloud/android/connection/src/main/java/org/openmobster/core/mobileCloud/android/module/connection/PolicyManager.java
The AndroidManifest declaration of the receiver:
<receiver android:name="org.openmobster.core.mobileCloud.android.module.connection.PolicyManager$PolicyReceiver"
android:label="OpenMobster Device Administrator"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
res/xml/device_admin.xml: http://openmobster.googlecode.com/svn/trunk/cloud/android/cloudManager/res/xml/device_admin.xml
This should give an idea of the PolicyManager code and its corresponding configuration.
As per providing a communication between the server and the device goes, you can use a persistent TCP connection between the two entities. Here is some sample code on how to do that
Creating and Managing a persistent TCP socket: http://openmobster.googlecode.com/svn/trunk/cloud/android/connection/src/main/java/org/openmobster/core/mobileCloud/android/module/connection/NotificationListener.java
Hope this helps with getting started
check of DevicePolicyManager, http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
specifically, the resetPassword, and lockNow() methods.
please read the entire device admin tutorial to understand how to use DPM in context, http://developer.android.com/guide/topics/admin/device-admin.html
as for locking from the website. android c2dm is the preferred way to get push messages to the device. http://code.google.com/android/c2dm/
note however that this is intended for occasional "wake up" messages, not for any sort of 2-way communication between the device and some other entity.