2017-04-05 7 views
0

文字列s5、s6、s7、s8をsmsに追加したいのですが、アンドロイドで実行されたアクションの後にメッセージs5、 s5までどのようにSMSを介してすべての文字列を送信することができます文字列s5、s6、s7、s8をsmsに追加します。android

    String s = n.getText().toString(); 
        String s1 = ci.getText().toString(); 
        String s2 = cn.getText().toString(); 
        String s3 = sr.getSelectedItem().toString(); 
        String s4 = mn.getText().toString(); 
        String s5 = ml.getText().toString(); 
        String s6 = spt.getSelectedItem().toString(); 
        String s7 = sui.getSelectedItem().toString(); 
        String s8 = d.getText().toString(); 


        SmsManager sms = SmsManager.getDefault(); 
        sms.sendTextMessage("phone number", null, 
            "Name:" + s + 
            "\nCollege id:" + s1 + 
            "\nContact no:" + s2 + 
            "\nYour Role:" + s3 + 
            "\nMachine Number:" + s4 + 
            "\nMachine Location:" + s5 + 
            "\nMachine Location:" + s6 + 
            "\nproblemDescription:" + s7 + 
            "\nroleCombobox:" + s8 
          , sentPI, deliveredPI); 
+0

s6とs7の後ろに '+ 'がありません – samgak

答えて

0

sendMultipartTextMessageを使用すると、長いメッセージをStringのArrayListに分割する必要があります。その後、必要な数のSMSを送信します。要するに:文字列の長さが160文字以上の場合より大きい場合

SmsManager sms = SmsManager.getDefault(); 
ArrayList<String> parts = sms.divideMessage(longMessage); 
sms.sendMultipartTextMessage(phoneNumber, null, parts, null, null); 
0

SMSの長さの制限は160文字です。

文字列を表示しないと文字列s5に問題はありません。実際の問題は文字数制限なので、SMSを2つの部分で送信できます。

+0

How ??教えてください –

0

その後、長さごとにいくつかの半分に文字列を分割stringbuilderを使用して確認することができます。また、文字列ビルダーを使用することは、performanceの観点からは良い選択です。

関連する問題