开发者

how do I add a hyperlink in sms message in android phone?

开发者 https://www.devze.com 2023-03-16 05:37 出处:网络
I want to send a sms message with the message body like \"where am I?\" when I click \"where am I?\",it will take me to the google map website with my location.

I want to send a sms message with the message body like "where am I?" when I click "where am I?", it will take me to the google map website with my location. My q开发者_如何转开发uestion is that how can I add this hyperlink in the "where am I?" message text? Is there any example that I can study?


SMSes are text-only, and they only allow 160 characters. What you are suggesting would include 'where am I?' in the 160 characters but also somehow include a very long web address.

The first thing you might want to do is make use of some sort of URL-shortening service. I don't have one that I can personally recommend but there are Django apps, among other things, and online services that you can hook into with an API (like bit.ly). That will get you a unique link to easily fit in the available characters of an SMS.

Most smart phones will parse a link and make it 'clickable', even if it is in an SMS. So, for example, you could make the text read:

Where am I? www.linkgoesh.ere/somehash 

The user should be able to click on the link and visit your website. It's not as elegant as what you're suggesting, but SMS is a (necessarily) limited format.


Try this code, it should resolve your issue.

String uri = "http://maps.google.com/maps?saddr="+latitude +","+longitude;                                  
SmsManager smsManager = SmsManager.getDefault();
StringBuffer smsBody = new StringBuffer();
//long number = Long.parseLong(get_number);
smsBody.append(Uri.parse(uri));
smsManager.sendTextMessage(get_number, null, smsBody.toString(), null, null);
0

精彩评论

暂无评论...
验证码 换一张
取 消