我想在短信中以链接形式制作字符串

时间:2017-04-20 07:11:52

标签: android

我希望链接在短信中如下图...我当前的代码是发送短信,如从应用程序到短信的字符串****我想在链接中使我的字符串简单

它是一个链接短信,但我的输出就像sms ..我想要这个输出

Its a link sms but my output is just as sms..i want this output

我的短信发送代码:

 public void SEND_SMS(){

     mynumber = (sharedPreferences.getString("string_number",""));
     myname = (sharedPreferences.getString("string_name",""));
     myremarks = (sharedPreferences.getString("string_remarks",""));
     myproject = (sharedPreferences.getString("string_project",""));
     String project = savePreferences(myproject,editproject.getText().toString());
     String remarks = savePreferences(myremarks,editremarks.getText().toString());
     String mysms = (sharedPreferences.getString("string_sms",""));
     //dialouge();
     combinedate = ""+y+month+d+"-"+h+":"+mins;
     combinevalue = "Name: "+myname+"\n"+"Project: "+project+"\n"+"Remarks: "+remarks+"\n"+"Type: "+enter;
     mobile = (sharedPreferences.getString("string_number",""));
     DBCreate();
     SubmitData2SQLiteDB();
     Toast.makeText(getApplicationContext(),"Thank You!",Toast.LENGTH_SHORT).show();
     try {
         byte[] data = combinevalue.getBytes("UTF-8");
         base64 = Base64.encodeToString(data, Base64.DEFAULT);

         byte[] dataname = myname.getBytes("UTF-8");
         stringname = Base64.encodeToString(dataname,Base64.DEFAULT);

         byte[] dataproject = project.getBytes("UTF-8");
         stringproject = Base64.encodeToString(dataproject,Base64.DEFAULT);

         byte[] dataremarks = remarks.getBytes("UTF-8");
         stringremarks = Base64.encodeToString(dataremarks,Base64.DEFAULT);

         byte[] datalong = longitude.getBytes("UTF-8");
         stringlong = Base64.encodeToString(datalong,Base64.DEFAULT);

         byte[] datalat = latitude.getBytes("UTF-8");
         stringlat = Base64.encodeToString(datalat,Base64.DEFAULT);

         byte[] datatype = enter.getBytes("UTF-8");
         stringtype = Base64.encodeToString(datatype,Base64.DEFAULT);

         byte[] datanumber = mobile.getBytes("UTF-8");
         stringnumber = Base64.encodeToString(datanumber,Base64.DEFAULT);

         byte[] datacombine = combinedate.getBytes("UTF-8");
         stringdate = Base64.encodeToString(datacombine,Base64.DEFAULT);

         allencoded = "name="+stringname+"&"+"project="+stringproject+"&"+"remarks="+stringremarks+"&"+"lat="+stringlat+"&"+"long="+stringlong+"&"+"mobile="+stringnumber+"&"+"type="+stringtype+"&"+"date="+stringdate;

         byte[] alldata = allencoded.getBytes("UTF-8");
         mydata = Base64.encodeToString(alldata,Base64.DEFAULT);




         base64 = combinevalue+"\n\n"+mysms+questionmark+mydata;

     } catch (UnsupportedEncodingException e) {
         e.printStackTrace();
     }

     SmsManager sms = SmsManager.getDefault();
     ArrayList<String> parts = sms.divideMessage(base64);
     sms.sendMultipartTextMessage(mynumber,null,parts,null,null);

}

1 个答案:

答案 0 :(得分:0)

我知道一个库为字符串制作链接。我用过它,那很好。 'Android的TextView的-LinkBuilder' https://github.com/klinker24/Android-TextView-LinkBuilder