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

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 question 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);

Related

Firebase Invites - SMS is not being send when using not-latin characters

I'm using Firebase-Invites to share an item using sms and email.
Email is working as expected but Sms is being send only if all the characters are in latin.
Note: I know there is a limit of 100 chars and i'm not exceeding it.
From #Oleg Cherr answer i realise there is a limit of 40(!) instead of 100 when using not-latin characters (even only one!).
So i searched and find BalusC answer to how to know if there is at least one not-latin character:
boolean valid = input.matches("\\p{L}+");
In this case i set another, shorter message and it seems to work perfectly.

What exactly is scAddress in SmsManager's sendTextMessage function?

I'm working on an application that will be sending a text message to another person from the app (this is not being published to the Play Store). I am looking at the documentation for SmsManager, and there is a parameter (which I currently have null), scAddress, which is described by:
String: is the service center address or null to use the current default SMSC
In short, I don't want the app to use my actual phone number to send out this text message. What exactly is the "service center address?"
My application does not care about receiving a response for the text message. What happens if the user replies to this message? Is this related to the service center address?
Thank you!

HTML link for add contact to whatsapp

I need to put a deep link in my HTML for adding a contact to the Phone and then begin a new conversation in whatsapp.
I found this code
Send text to whatsapp
And this one:
Send text to user
I need to open a conversation with a specific contact even if I don't have the contact. My first question is, where can I get the username for whatsapp?
Having the abid I can try if it works but I dont know where to get that data.
Thanks a lot
Send Message
Without "+" or "00" at the beginning, just start country code and the number.
Example USA is +12025599025 then in the code given, replace NUMBER with 12025599025
this was worked for me:
whatsapp://send?text=MESSAGE&phone=+NUMERO&abid=+NUMERO
Obviusly "+NUMERO" is the wsp number and "MESSAGE" the preloaded message put in inhref` attribute
Recent solution (July 2017)
Malki's answer does solves the issue, but recently there's been published an official Whatsapp API I mentioned in THIS OTHER ANSWER (because S.O. policies I had to put a link to the solution, no duplicates).
This doesn't directly add the contact but allows you to open a copnversation with a concrete number, it can be very usefull to use it in your web sites. I've just found that it is possible to open a conversation to a number Using Click to Chat
To create your own link with a pre-filled message that will
automatically appear in the text field of a chat, use
https://wa.me/whatsappphonenumber/?text=urlencodedtext where
whatsappphonenumber is a full phone number in international format and
URL-encodedtext is the URL-encoded pre-filled message.
Example:https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale
NOTE: It opens WhastApp application if you click the link using a mobile phone browser (at least from Android)
The ABID (address book ID) is for an ID, not a name on your contact list.
In Whatsapp URL Scheme Documentation There are not (yet) documentation to send message to a specific contact.
The best way i found is to add the contact using this html code:
add number
(this will open Contacts app from your phone)
This is how you can create a link to send a WhatsApp message to a particular number.
Notice that you don't need to add the '+' symbol before the country -code. Just start with the country-code followed by the WhatsApp number:
Link Icon

How I can send message in android without show message in the SMS Inbox?

Im can send sms with this code :
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("5556", null, "Hi Havij", null, null);
But I dont like my message go in Inbox ! I want dont show it Nowhere ...
One possible solution might be deleting that SMS, But according to Google Docs after 4.4 no app can delete messages except the default messaging app:
Also, the system now allows only the default app to write message data to the provider, although other apps can read at any time. Apps that are not the user's default can still send messages
and for more info I suggest u see this.
UPDATE
after a little search I found what you need but as I told you before it seems its impossible in android 4.4 but if you want to do such work with lower versions of android please take a look at
this
One possible solution is you may send data SMS.
SmsManager smsManager = SmsManager.getDefault();
byte[] messageInBytes = stringMessage.getBytes();
smsManager.sendDataMessage(Mobile_no, null, SMS_PORT, messageInBytes , null, null);

Sending an SMS using Google Voice

I have an app where I need to be able to send SMS messages. I have the code to send them directly, but I would like to give the option to use Google Voice to users who don't have messaging plans. Does anyone know how to do this? I can't seem to find the way. Here is the way I am doing it now:
StringBuffer buffer = new StringBuffer();
buffer.append("GEOC ");
buffer.append(mLogType.getSelectedItemPosition() == 0 ? "#" : "x");
buffer.append(mGeocache.getWaypoint()).append(" ");
if(mLogEdit.getText().length() > 0)
{
buffer.append(mLogEdit.getText().toString());
}
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("41411", null, buffer.toString(), null, null);
You want to use an SMS Intent.
That will give the user the option to select (or skip this step if he already have a default option) which SMS sending utility he want's to use.
several applications register themselves as such, such as skype, yahoo hub, google voice, etc.
So using a Intent, you tell android to use whatever the user wants to send the text message to a sms recipient.
It's my belief that the user must have a google voice account setup and have the voice app installed. Then when you fire an intent to send an sms it will be their preference to use google voice or not.
I've found a site where they've written their own google voice java library that you can import into your app and use. I just downloaded it yesterday so can't help with specific yet, but go ahead and take a look. It looks really promising.
http://code.google.com/p/google-voice-java/

Categories

Resources