I want to use the existing sms application in android phones and add some features.
How to use them.i want the entire functionality including interface, logging as thread etc.
Thanks in advance
Not sure what you want to do here:
Simple way:
SmsManager mgr = SmsManager.getDefault();
String phoneNumber = "12345667860";
mgr.sendTextMessage(phoneNumber, null, "Sup bbz", null, null);
Alternate way using intents:
String phoneNumber = "12345667860";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", phoneNumber, null)));
Android uses intents to communicate between processes in the dvm.
Read the documentation to know more about the exposed api
Related
I have a scenario in mind and I don't know if it's possible:
Open the SMS interface from my app.(I can make this part)
Use the interface to write the message and search the contact(s).
When send button is pressed I want to store the information in my app and send it later.(I don't know if this is possible, if it is please give me some help)
Sounds possible to me. You probably want the SMSManager to send a text... source
// Simplified...
String phoneNo = "8675309";
String sms = "Beni, I've got your number";
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
} catch (Exception e) {
e.printStackTrace();
}
Regarding searching the contacts and sending the text at a later time, it would be helpful if you could provide more specifics.
How will your app search the contacts? Display a full list for them to pick from? Allow them to enter text to match against the contact's name?
When you say "Send it later", what are your constraints for later?
For example, you could simply bring up their phone's contact viewer, and let them choose...
This below approach opens the app but doesn't do anything.
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String phoneNumber = "phone number here";
String text = "Hi belated happy diwali";
Intent smsIntent = getPackageManager().getLaunchIntentForPackage("sun.way2sms.hyd.com");
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", phoneNumber);
smsIntent.putExtra("sms_body", text);
startActivity(smsIntent);
}
});
As per my knowledge, like default SMS Manager you can't send message directly with other apps....like way2sms / whatsapp. If and only if they are providing there SDK and with that option.
Do you know the 'key' -> "address" and "sms_body" are using by way2sms app to receive your data!!!!
For Eg: Facebook you can post directly with ur app by using some user permissions.
If you are using a third party app the best you can do is launch the third party app with the data pre filled just like the native app.
If the third party app provides any support for sending sms in the background (like a broadcast or something) then you can do it. Although the chances of any app having such functionality is low
When I use the following code:
String phoneNumber="0527276513";
Uri uri = Uri.parse("smsto:" + phoneNumber.toString());
Intent smsSIntent = new Intent(Intent.ACTION_SENDTO, uri);
String smsBody="hii";
smsSIntent.putExtra("sms_body", smsBody.toString());
startActivity(smsSIntent);
The code opens the default application for sending SMS in my phone with the SMS body but the message doesn't get sent.
How do I send an SMS dynamically?
It is simple. Before making any changes please update your manifest by adding the following line:
<uses-permission android:name="android.permission.SEND_SMS"/>
And in your method/function use the following code:
String phoneNumber = "myphonenumber";
String message = "mymessage";
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
Note that on Android 4.4 (KitKat) and higher devices, only the default SMS app can send text messages, per the blog post.
Assuming your app is not a full fledged SMS replacement app, the approach you have outlined is the correct one to ensure your app works on all Android versions.
Im a new android developer.
I want to send a SMS which contains my current location. I know how to get my location coordinates. But what I want is send like a URL, and the User could open and see where I am(For example: With waze you can share you location and I think also with google maps app). I tried with google maps API but I didnt find like an option to generate a URL.
Can anybody give some ideas?Or an API?
Thanks everyone!!!
I guess this is what you need.
public void sendLocationSMS(String phoneNumber, Location currentLocation) {
SmsManager smsManager = SmsManager.getDefault();
StringBuffer smsBody = new StringBuffer();
smsBody.append("http://maps.google.com?q=");
smsBody.append(currentLocation.getLatitude());
smsBody.append(",");
smsBody.append(currentLocation.getLongitude());
smsManager.sendTextMessage(phoneNumber, null, smsBody.toString(), null, null);
}
I would use a map overlay instead of default maps.
I have developed an app which uses the location feature and shows in map. See it on google play.
"Wherez U" https://play.google.com/store/apps/details?id=com.kabhos.android.apps.knowmylocation
String uri = "http://maps.google.com/maps?saddr=" + currentLocation.getLatitude()+","+currentLocation.getLongitude();
SmsManager smsManager = SmsManager.getDefault();
StringBuffer smsBody = new StringBuffer();
smsBody.append(Uri.parse(uri)); `
smsManager.sendTextMessage(phonenumber, null, smsBody.toString(), null, null);
you have to parse that string to uri. it worked for me
refer this link
http://javapapers.com/android/get-current-location-in-android/
after getting it send that location using sms api .
I was also facing the same issue and was not able to generate URL to be send to the receiver and I found this. Here I have a link in which we have to pass the LAT and LONG of the current location of sender and then you have to just send this link to your receiver.
https://www.google.com/maps/preview/#(latitude),(longitude),(zoom level)z
https://www.google.com/maps/preview/#-15.623037,18.388672,8z
You can also try first to open this link in your browser and then apply it to your project
I am working on an android application , in which we are dealing with android sms service. I just want to know that is it possible to send sms to other non android device using the below method.
SmsManager sm = SmsManager.getDefault();
// HERE IS WHERE THE DESTINATION OF THE TEXT SHOULD GO
String number = "6508570720";
sm.sendTextMessage(number, null, "Test SMS Message", null, null);
OR
Do we have any other method to achieve this task.
SMS is not a device specific feature. It is provided and controlled by Telecom / Cellular service provider. So the code should send SMS to any phone from your Android device.
You may also try the following code:
String number = "6508570720";
String message = "hi there";
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + number ) ); intent.putExtra( "sms_body", message ); startActivity( intent );
Yep, This should work for sending sms to non-android devices as well.