Use reflection to obtain hidden methods in Android

Source: Internet
Author: User
Public void insert () {smsmanager = smsmanager. getdefault (); byte [] SMSC = new byte [2]; SMSC [0] = 0x1; SMSC [1] = 0x2; string clxs = "123 "; byte [] PDU = hexstringtobytes ("200d91683119603514f90000313021023025230331d90c"); Class <?> C; try {c = Class. forname ("android. telephony. smsmanager "); method [] MS = C. getmethods (); For (method M: MS) {system. out. println (M. getname (); Class <?> [] Cx = M. getparametertypes (); For (class <?> Cx1: Cx) system. out. println (cx1.getname (); system. out. println (M. getreturntype ();} method M = C. getmethod ("copymessagetoicc", new class [] {byte []. class, byte []. class, Int. class}); object S = m. invoke (smsmanager. getdefault (), null, PDU, 1);} catch (exception e) {e. printstacktrace ();} // smsmanager. copymessagetoicc (null, PDU, 1 );}

 This method is required when we copy text messages to the SIM card. However, in Android hide, then we use the reflection method to obtain this method: // smsmanager. copymessagetoicc (null, PDU, 1); 
Code . I believe you can understand it at first glance, I will not talk about it here. Come on!
Related Article

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.