DevicePolicyManager, locknow when gcm message received

我的未来我决定 提交于 2019-12-12 03:09:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!