Android sendTextMessage sends two identical messages on exceution

后端 未结 4 1067
陌清茗
陌清茗 2021-01-14 07:59

I\'ve been working on an app that sends SMS-messages. The problem I have is that the sendTextMessage method sends two messages with the same content. How do I fix that?

4条回答
  •  萌比男神i
    2021-01-14 08:40

    Following code works fine, S2 with ICS:

    void sendMessageGTI9100ICS(String number, String msg) throws Exception {
        SmsManager m = SmsManager.getDefault();
    
        Class aclass[] = new Class[9];
    
        aclass[0] = String.class;
        aclass[1] = String.class;
        aclass[2] = ArrayList.class;
        aclass[3] = ArrayList.class;
        aclass[4] = ArrayList.class;
        aclass[5] = Boolean.TYPE;
        aclass[6] = Integer.TYPE;
        aclass[7] = Integer.TYPE;
        aclass[8] = Integer.TYPE;
    
        Method method = m.getClass().getMethod("sendMultipartTextMessage", aclass);
    
        Object aobj[] = new Object[9];
        aobj[0] = number;
        aobj[1] = null;
        aobj[2] = m.divideMessage(msg);
        aobj[3] = null;
        aobj[4] = null;
        aobj[5] = Boolean.valueOf(false);
        aobj[6] = Integer.valueOf(0);
        aobj[7] = Integer.valueOf(0);
        aobj[8] = Integer.valueOf(0);
    
        method.invoke(m, aobj);
    }
    

提交回复
热议问题