I work with sending SMS with the GoogleMaps link, but in some cases, the phone does not send, I can not know the reason, other links are sent normally.
Here is the image of the message:
I would like some help in resolving this issue. And, importantly, The idea of using SMS is to not need the internet.
Here is the code I use for generation:
String uri = "http://maps.google.com/maps?q=" + lat + "," + lng;
if (!preferences.getNumber(activity).equals("")) {
smsBody.append(Uri.parse(uri));
String phone1 = preferences.getNumber(activity);
try {
smsManager.sendTextMessage(phone1, null, msgASerEnviada, null, null);
smsManager.sendTextMessage(phone1, null, smsBody.toString(), null, null);//mensagem com o link
Toast.makeText(activity, "Sent to " + phone1, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(activity, "Something wrong", Toast.LENGTH_SHORT);
}
}
resolved by removing the http: //
Related
Here the address stores current location of the device, which works. I get a toast that says SMS Sent but no sms is actually sent from the device. If the same code is used before finding the location, it works perfectly.
public void sendSMS()
{
String phoneNo = "+918110020302";
String message="Our Customer "+" has booked Cab no "+" using our application CabBooking and is cureently at location: "+address;
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, message, null, null);
q.setText(message +phoneNo);
Toast.makeText(getApplicationContext(), "SMS sent.", Toast.LENGTH_LONG).show();
}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
If you haven't seen it yet, here is a working example: http://www.mkyong.com/android/how-to-send-sms-message-in-android/
It may depend on your network. If you are running this inside Android Studio's emulator, it may not work because it does not actually have cell service from within the emulator. You may need to be connected to a different network, or your cellular network.
Sorry if this question is already asked or seems stupid but i am stuck . I am writing an android application in which app sends different messages to different people the first one successfully send but there is a problem with the second one it doesn't show me error but it doesn't send the second message here is a portion of my code
public void sendSMSMessenger(){
Log.i("Send SMS", "");
try {
// SmsManager smsManager = SmsManager.getDefault();
SmsManager.getDefault().sendTextMessage(Emergencyphonenumber, null, "There is an emergency with your "+PatientRelationship+" "+Patientname+" please open the link to find the location "+"https://www.google.com/maps/place/"+latitude+","+longitude, null, null);
Toast.makeText(this, "Message Sent (Relative)", Toast.LENGTH_SHORT).show();
SmsManager.getDefault().sendTextMessage(Doctorphonenumber, null, "There is an emergency with your patient named "+Patientname+" please open the link to find the location "+"https://www.google.com/maps/place/"+latitude+","+longitude, null, null);
Toast.makeText(this, "Message Sent (Doctor)", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(this, "Message Sending failed", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
Thank you....
You can not send messages simultaneously. In a way its hard for network to process all the messages collectively. Wait a little. Increase the time.
I want to develop a project to send text messages in android using sendTextMessage() from android.telephony.SmsManager. When the message is sent a prompt appears. I want to know where can I find that code?
try below code:-
buttonSend.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
String phoneNo = textPhoneNo.getText().toString();
String sms = textSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
I believe you have not search it:
Question : Sending text messages programmatically in android already exists.
you can try this code also:
public void sendLongSMS() {
String phoneNumber = "0123456789";
String message = "Hello World! Now we are going to demonstrate " +
"how to send a message with more than 160 characters from your Android application.";
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(message);
smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
}
Code for Toast(prompt)
Toast.makeText(getContext(), "Your message",Toast.LENGTH_LONG).show();
Sms Manager
Toasts
Read this : What types of questions should I avoid asking? before asking question here.
I have this code for sending sms to cellphones .
However it doesn't seem to deliver the sms, am i missing something ? should i buy some account from cellular companies ?
public void sending (View v)
{
String messageToSend = "this is a message";
String number = "1234567890";
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, messageToSend, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!", Toast.LENGTH_LONG)
.show();
e.printStackTrace();
}
}
I have tried to send sms to my number many times,i used my number as "1234567890" using it as i dial it every day, then i tried using it with the international code "+9721234567890"
thanks in advance
I want to get first and last name of a google account using gdata library. I have the auth token(I take it from android device - send it to my java servlet- then should add an insert into a mysql db with first, last, display name and provider_uid(provider_uid is the form of https://www.google.com/accounts/o8/id?id=AItOawmyn...)).
I used Contacts feed like this(without success):
public String tryGoogleAuthentication(String auth_token){
ContactsService contactsService = new ContactsService("...");
contactsService.setUserToken(auth_token);
//contactsService.setAuthSubToken(auth_token);
ContactFeed feed = null;
try {
feed = contactsService.getFeed(new URL("https://www.google.com/m8/feeds/contacts/" + "someEmail#gmail.com" + "/full?max-results=10000"), ContactFeed.class);
} catch (IOException e) {
e.printStackTrace();
return CONST.GOOGLE_AUTH_INVALID_TOKEN;
} catch (ServiceException e) {
e.printStackTrace();
return CONST.GOOGLE_AUTH_INVALID_TOKEN;
} catch (NullPointerException e) {
e.printStackTrace();
return CONST.GOOGLE_AUTH_INVALID_TOKEN;
}
if (feed == null)
return "";
String externalId = feed.getId();
Person person = feed.getAuthors().get(0);
String email = person.getEmail();
String name = person.getName();
String nameLang = person.getNameLang();
String extensionLocalName = person.getExtensionLocalName();
String uri = person.getUri();
System.out.println("externalId: " + externalId);
System.out.println("email: " + email);
System.out.println("name: " + name);
System.out.println("nameLang: " + nameLang);
System.out.println("extension local name: " + extensionLocalName);
System.out.println("URI: " + uri);
System.out.println(feed.getSelf().getEntries().get(0).getTitle().getPlainText());
return CONST.STATUS_OK;
}
Also,
System.out.println("ID: " + feed.getSelf().getEntries().get(0).getId());
will output:
ID: http://www.google.com/m8/feeds/contacts/someEmail%40gmail.com/base/c....
but I want something like this:
https://www.google.com/accounts/o8/id?id=AItOawmyn...
I need this to insert into an existing data base.
Please note that I want the info only for the account, not for it's contacts.
Thanks,
Alex
Please see this answer from google groups for resolution. The problem is that I cannot access user profile with the auth_token taken from the android because it's a Client Login token, and Client Login does not have a scope for accessing user's profile. I integrated OAUTH login in android like this and with the token returned, I can access user's profile.
Alex.