mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Add support for setting sms body using uri "sms:#?body=text".
This commit is contained in:
parent
1fc56921aa
commit
7344964c05
@ -946,19 +946,38 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If sms:5551212
|
// If sms:5551212?body=This is the message
|
||||||
else if (url.startsWith("sms:")) {
|
else if (url.startsWith("sms:")) {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
|
||||||
intent.putExtra("address", url.substring(4));
|
// Get address
|
||||||
intent.setType("vnd.android-dir/mms-sms");
|
String address = null;
|
||||||
startActivity(intent);
|
int parmIndex = url.indexOf('?');
|
||||||
} catch (android.content.ActivityNotFoundException e) {
|
if (parmIndex == -1) {
|
||||||
System.out.println("Error sending sms "+url+":"+ e.toString());
|
address = url.substring(4);
|
||||||
}
|
}
|
||||||
return true;
|
else {
|
||||||
}
|
address = url.substring(4, parmIndex);
|
||||||
|
|
||||||
|
// If body, then set sms body
|
||||||
|
Uri uri = Uri.parse(url);
|
||||||
|
String query = uri.getQuery();
|
||||||
|
if (query != null) {
|
||||||
|
if (query.startsWith("body=")) {
|
||||||
|
intent.putExtra("sms_body", query.substring(5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intent.setData(Uri.parse("sms:"+address));
|
||||||
|
intent.putExtra("address", address);
|
||||||
|
intent.setType("vnd.android-dir/mms-sms");
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (android.content.ActivityNotFoundException e) {
|
||||||
|
System.out.println("Error sending sms "+url+":"+ e.toString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// All else
|
// All else
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user