public void insert() {SmsManager 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);}
在我們往sim卡裡面複製簡訊的時候,需要用到這個方法,但是在Android中式hide的,那麼我們就是用反射的方法來擷取出這個方法來:// smsManager.copyMessageToIcc(null, pdu, 1);
代碼寫出來,相信你一看就懂,在此我也不多說了,加油!