反射使用

 Class localClass1 = Class.forName("com.yulong.android.telephony.CPSmsManager");
     Constructor localConstructor = localClass1.getDeclaredConstructor(new Class[0]);
     localConstructor.setAccessible(true);
     Object sms_class = localConstructor.newInstance(new Object[0]);
     Class[] sendMessagePara={ String.class, String.class,
ArrayList.class, ArrayList.class, ArrayList.class, int.class};
     Class[] devidePara={ String.class};
     Method sendMultipartMessage = localClass1.getDeclaredMethod("sendDualMultipartTextMessage", sendMessagePara);
     Method deivedMessage = localClass1.getDeclaredMethod("divideMessage",devidePara);
     
     
     Object[] arrayOfObject2 = new Object[6];
     arrayOfObject2[0] = phoneNumber;
     arrayOfObject2[1] = null;
     arrayOfObject2[2] = null;
     arrayOfObject2[3] = null;
     arrayOfObject2[4] = null;
     Integer localInteger = Integer.valueOf(0 + 1);
     arrayOfObject2[5] = localInteger;
     
     ArrayList<String> magArray =(ArrayList<String>) deivedMessage.invoke(sms_class, "hello");
     Object localObject2 = sendMultipartMessage.invoke(sms_class,phoneNumber,null,magArray,null,null,2);
   }catch (Exception localException){
    localException.printStackTrace();
   }

你可能感兴趣的:(反射使用)