Mobile Remote Control

Source: Internet
Author: User

1. Device Manager

Remote control of mobile phone the most important thing is to get the external application access to the management device, these permissions in the Device Manager to register, you can see in our settings-> security---Device Manager.

A, declare a manager permission requirements list: Myadmin.xml

1 <?XML version= "1.0" encoding= "Utf-8"?>2 3 <Device-adminxmlns:android= "Http://schemas.android.com/apk/res/android" >4 5 <!-- 6 7 Restricting password types8 9 See how to sign inTen  One Reset Password A  - Force lock Screen -  the Clear Data -  - Change Password -  + Encryption Device -  + turn off the camera head A  at  - -  - <uses-policies> -  - <Limit-password/> -  in <Watch-login/> -  to <Reset-password/> +  - <Force-lock/> the  * <Wipe-data/> $ Panax Notoginseng <Expire-password/> -  the <Encrypted-storage/> +  A <Disable-camera/> the  + </uses-policies> -  $ </Device-admin> $  -  

B. Declare a Device Manager's calling component: Myadminreceiver.java

1  Public classMyadminreceiverextendsdeviceadminreceiver{2 3 @Override4 5       Public voidonenabled (Context context, Intent Intent) {6 7               //TODO auto-generated Method Stub8 9               Super. onenabled (context, intent);Ten  One      } A  - @Override -  the       Public voidondisabled (Context context, Intent Intent) { -  -               //TODO auto-generated Method Stub -  +               Super. ondisabled (context, intent); -  +      } A  at}

C, register this component in Manifest.xml, stating which permission Declaration table is used for the component

1 <receiverAndroid:name= "Com.example.cleaner.MyAdminReceiver" >2 3       <Meta-data4 5            Android:name= "Android.app.device_admin"6 7 Android:resource= "@xml/myadmin" />8 9             <!--Specify Device Management permission settings table -Ten  One       <Intent-filter> A  -          <ActionAndroid:name= "Android.app.action.DEVICE_ADMIN_ENABLED" /> -  the                 <!--get the broadcast that the Device Manager opens - -  -       </Intent-filter> -  +  </receiver>

D. Start the Device Manager component registration request to start the Device Manager registration screen

1 //get a Device Manager2 3Devicepolicymanager Devicepolicymanager =(Devicepolicymanager) Getsystemservice (context.device_policy_service);4 5 //new component to start the Registration Manager interface6 7ComponentName componentname =NewComponentName (8 9Mainactivity. This, Myadminreceiver.class);Ten  OneIntent Intent =NewIntent (devicepolicymanager.action_add_device_admin); A  - Intent.putextra (Devicepolicymanager.extra_device_admin, -  the componentname); -  -StartActivity (Intent);

2. MD5 Encryption Module
As an anti-theft application, set only the owner to enter the password is necessary, the general password is kept in the database, so that easy to be taken out to view, it is necessary to encrypt the password.
MD5 is message-digest algorithm 5 (Information-Digest algorithm 5), which is used to ensure complete and consistent information transmission. is one of the widely used hashing algorithms (also translation digest algorithm, hashing algorithm), mainstream programming language has been widely MD5 implemented.

The calculation of data (such as Chinese characters) as another fixed length value is the basic principle of the hashing algorithm, and the predecessor of MD5 is MD2, MD3 and MD4.

MD5 's role is to allow bulk information to be "compressed" into a confidential format before signing a private key with a digital signature software (that is, converting an arbitrary-length byte string into a long hexadecimal string).

1        Try {2 3MessageDigest messagedigest = messagedigest.getinstance ("MD5");//MD5 Encryption Module4 5 byte[] bytes = Messagedigest.digest (Password.getbytes ());//encrypt password into byte code6 7StringBuffer SB =NewStringBuffer ();8 9 String tmp;Ten  One                         for(inti = 0; i < bytes.length; i++) { A  -TMP = integer.tohexstring (0xFF & Bytes[i]);//Convert to hexadecimal -  the                                  if(tmp.length () = = 1) { -  -Sb.append ("0" + tmp);//complement 0 -  +}Else -  + sb.append (TMP); A  at                        } -  -                        returnsb.tostring (); -  -}Catch(nosuchalgorithmexception e) { -  in                        Throw NewRuntimeException ("No This encryption algorithm" +e); -  to               } +  -  

3, positioning implementation
A, the SIM card is replaced to the trust number text message, The secret hair

1Telephonymanager Telephonymanager =(telephonymanager) Context2 3 . Getsystemservice (context.telephony_service);4 5 //get the Telephoneymanager object .6 7String currentsimstring =Telephonymanager.getline1number ();8 9 //to get the current SIM card number, you need to permission:read_phone_stateTen  OneString Protectedsim = sppreferences.getstring ("simserial", "" "); A  -Smsmanager Smsmanager =Smsmanager.getdefault (); -  the //get the SMS manager for sending text messages what you need -  -String number = sppreferences.getstring ("number", "" "); -  + if(isprotected) { -  +               if(!currentsimstring.equals (Protectedsim)) { A  at               //send a text message, there are 5 parameters, the first is to send to the address, the second is the sender, can be set to NULL, the third is to send the information, the fourth is the sending status, the fifth is sent, all can be reset to null -  -Smsmanager.sendtextmessage (number,NULL, "You are one number:" -  -+ Protectedsim + "friend may be stolen, now his mobile phone number is:" -  in+ currentsimstring + ", please notify the friend in time, thank you! ",NULL,NULL); -  to                        } +  -}

4. Erase data and lock screen

1 Devicepolicymanager manager = (devicepolicymanager) context  2  3                                          . Getsystemservice (context.device_policy_service); 4 5 manager.wipedata (0); // Clear Data 6 7 Manager.resetpassword (lockstring[2], 0); 8 9               // to lock the screen Ten  Manager.locknow ();

Remote control of the phone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.