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);
代码写出来,相信你一看就懂,在此我也不多说了,加油!