问题
I am trying to remotely lock my phone when a gcm PUSH notification with a keyword arrives.
Inside the GcmIntentService class, within the onHandleIntent I have included
message = extras.getString("message");
if(message.equals("LOCK")){
gcmaction(message);
}
else{
sendNotification("Message: " + extras.getString("message"));
Log.i(TAG, "Message: " + extras.toString());
}
So if a message arrives saying LOCK, it should go to the gcmaction method. Otherwise go to the notification method.
private void gcmaction(String string) {
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
//lock action
mDPM.resetPassword(Password,
DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
mDPM.lockNow();
}
sendNotification is correctly showing notfications but nothing happens when I send "LOCK" ... can someone tell me what I am missing ?
Thanks
来源:https://stackoverflow.com/questions/19210135/devicepolicymanager-locknow-when-gcm-message-received