能力值:
( LV2,RANK:10 )
|
-
-
2 楼
呃,在线等了好久啊
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
呃,我把代码发上来,我不懂为什么object对像会是空的。try {
Class<?> smsManagerClass = null;
Class<?> factoryClass=null;
@SuppressWarnings("rawtypes")
Class[] divideMessagePamas = { String.class };
@SuppressWarnings("rawtypes")
Class[] sendTextPamas = { String.class,String.class, ArrayList.class,ArrayList.class,ArrayList.class };
Method divideMessage = null;
Method sendText = null;
factoryClass= Class.forName("com.android.internal.telephony.PhoneFactory");
smsManagerClass=Class.forName("android.telephony.SmsManager");
//Method[] methods=smsManagerClass.getDeclaredMethods();
//
// Method method = smsManagerClass.getMethod("getDefault", new Class[]{});
/* Object smsManager = method.invoke(smsManagerClass, new Object[]{});
Method isMultiSim=smsManagerClass.getMethod("sendMultipartTextMessageWithEncodingType", sendTextPamas);
divideMessage=smsManagerClass.getMethod("divideMessage",divideMessagePamas);
sendText =smsManagerClass.getMethod("sendTextMessage",sendTextPamas);
ArrayList<String> magArray = (ArrayList<String>)divideMessage.invoke(smsManager, content);
} */
Method[] methods=factoryClass.getDeclaredMethods();
Method getcdmaphoneMethod=factoryClass.getMethod("getCdmaPhone", new Class[]{ });
Method getgsmphonemMethod=factoryClass.getMethod("getGsmPhone", new Class[]{ });
divideMessage=smsManagerClass.getMethod("divideMessage", divideMessagePamas);
sendText=smsManagerClass.getMethod("sendMultipartTextMessage", sendTextPamas);
Object object=factoryClass.newInstance();
if(phoneType==1)
{
Object cdmaphoneObject=getcdmaphoneMethod.invoke(object, new Object[]{});
@SuppressWarnings("unchecked")
ArrayList<String> magArray = (ArrayList<String>)divideMessage.invoke(cdmaphoneObject, content);
sendText.invoke(cdmaphoneObject,phone,"",magArray,null,null);
}
else if(phoneType==2)
{
Object gsmphoneObject=getgsmphonemMethod.invoke(null, new Object[]{});
ArrayList<String> magArray = (ArrayList<String>)divideMessage.invoke(gsmphoneObject, content);
sendText.invoke(gsmphoneObject,phone,"",magArray,null,null);
}
else {
}
}
catch(IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch(SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch(NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (InstantiationException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
嗯,懂了, 是不可以的,因为SENDMULTIPARTMESSAGE是SMSMANAGER的对像,不是PHONE的对像
|
能力值:
( LV5,RANK:70 )
|
-
-
5 楼
LZ开启自问自答模式~
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
没办法啊,没人回答,自己又在那蛋疼的调试,发现了新的问题就来说明下。
|