0
我正在嘗試從手機發送短信到另一個手機。 SMS包含一個ftp鏈接。 例如,我想發送以下鏈接:ftp://ftp.example.com。 當用戶打開短信時,該鏈接將如同郵件正文中的ftp:// ftp.example.com。 當用戶點擊這個鏈接,Chrome瀏覽器會顯示該鏈接:http://ftp.example.comandroid手機 - 用ftp鏈接發送短信
感謝的,伊詹
我正在嘗試從手機發送短信到另一個手機。 SMS包含一個ftp鏈接。 例如,我想發送以下鏈接:ftp://ftp.example.com。 當用戶打開短信時,該鏈接將如同郵件正文中的ftp:// ftp.example.com。 當用戶點擊這個鏈接,Chrome瀏覽器會顯示該鏈接:http://ftp.example.comandroid手機 - 用ftp鏈接發送短信
感謝的,伊詹
如果您正在使用的Android 內置的短信應用發送消息,那麼你的代碼像這個 -
String smsBody = "ftp://ftp.example.com";
String phNumber = "123456";
Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address",phNumber); //optional, in case you want a default phone number
smsIntent.putExtra("sms_body",smsBody);
startActivity(smsIntent);
如果您使用的是SmsManager發送郵件,那麼代碼像這個 -
String smsBody = "ftp://ftp.example.com";
String phNumber = "123456";
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phNumber, null, smsBody, null, null);
而且不要忘了給兩者的SEND_SMS許可。
<uses-permission android:name="android.permission.SEND_SMS" />
希望這會對你有幫助。
嗨,謝謝你的評論。我的問題與代碼無關。以另一種方式發送的鏈接。我想通過標準SMS(Android操作系統)將鏈接從一部手機發送到另一部手機。 – idan