Is there anyone from Japan ? I have a question about Japan mobile network operators (Docomo, AU) and their phones: are they able to send/receive a long SMS (longer than 160 latin characters / 70 japanese characters)? or they are splitting the SMS in two fragments sent separately?
In my app, I want to send a long SMS using SMSManager's sendMultiPartTextMessage and I want to know if I can use it or send multiple SMS fragments using just sendTextMessage.
Thank you!
As per documentation, that's how you can send multi-parts message:
final String phoneNumber = "1111111111";
final String message = "this is text body for multi part sms...bla bla bla...";
SmsManager sms = SmsManager.getDefault();
ArrayList<String> parts = sms.divideMessage(message);
sms.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
Related
I am working on an application which is sending text and image messages. I am sending Text and Image using SmsManager in my Application as below. The problem is, this is sending separate messages for every image and text I am sending thus not getting in exact order, but I want to send and get message in exact order.
final PendingIntent pendingIntent = PendingIntent.getBroadcast(
NewLeaveItemActivity.this, 0, new Intent(ACTION_MMS_SENT), 0);
SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
mainImageContentUri, null, null,
pendingIntent);
SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
qRCodeContentUri, null, null,
pendingIntent);
SmsManager.getDefault().sendMultimediaMessage(getApplicationContext(),
storeContentUri, null, null,
pendingIntent);
PendingIntent intent = PendingIntent.getBroadcast(
NewLeaveItemActivity.this, 0, new Intent(ACTION_MMS_RECEIVED), 0);
SmsManager.getDefault().sendTextMessage(mEditMobileNew.getText().toString().trim(), null, bellowMessage, pendingIntent, intent);
It wouldn't be a professional or better way to split the MMS into 2 or 3 parts and send them separately. There would be a better way so that we can control what order they are received in?
Please help me.
use this amazing library to send media through sms
https://github.com/klinker41/android-smsmms
Create one large mms message. Convert all sms into mms too.
Api will automatically divide into multiple mms and will be in order.
Don't use SMS all messages should be part of a big mms.
method used here
divideMessage
Added in API level 4
public ArrayList<String> divideMessage (String text)
Divide a message text into several fragments, none bigger than the maximum SMS message size
.
sendMultipartTextMessage
Added in API level 4
public void sendMultipartTextMessage (String destinationAddress,
String scAddress,
ArrayList<String> parts,
ArrayList<PendingIntent> sentIntents,
ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS. The callee should have already divided the message into correctly sized parts by calling divideMessage.
I am using this code to send messages:
private void sendSMS(String phoneNumber, String message) {
Log.d("phoneNumber", phoneNumber);
Log.d("Message", message);
PendingIntent pi = PendingIntent.getActivity(mContext, 0, new Intent(
mContext, Object.class), 0);
smsManager.sendTextMessage(phoneNumber, null, message, pi, null);
}
It is not sending the messages with apostrophe. Here are the messages I tested:
Sorry, busy right now with a live person. I’ll contact you when I’m free.
Sorry, busy right now with a live person. I will contact you when I am free.
'
1 and 3 didn;t worked. But 2 worked. (yes... I sent only apostrophe in 3rd sms). Pretty weird. Any ideas?
If you want to send Apostrophe in SMS you have to use the escape character for an apostrophe. Putting a backslash character followed by a quote ( \" or \' ) will work.
In this case, your string should look like this "Sorry, busy right now with a live person. I\'ll contact you when I\'m free."
my app need's to send data to another android device so far its sending it through sms messages that gets blocked in the other android device ... but since the kitkat version i cant block them anymore.. is there anyway of sending push messages in the background to another user and receiving them back ? and if so... I would love to see any example ( I don't prefer GCM i think its way too complicated.. ) .
this is the code i am using to send the SMS message :
SmsManager sm = SmsManager.getDefault();
ArrayList<String> parts =sm.divideMessage(String.valueOf(points));
int numParts = parts.size();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
for (int i = 0; i < numParts; i++) {
sentIntents.add(PendingIntent.getBroadcast(getBaseContext(), 0, getIntent(), 0));
// deliveryIntents.add(PendingIntent.getBroadcast(getBaseContext(), 0, data, 0));
}
sm.sendMultipartTextMessage(number,null, parts, sentIntents, deliveryIntents);
SmsManager.getDefault().sendTextMessage(number, null, String.valueOf(points), null, null);
}
Looking for something similar just for the push messages.
You could send a data SMS. They operate differently than a regular SMS because they use a port upon sending, and so you specify that same port on the receivers handset. This avoids the problem of competing intent filter priority on the SMS receiver.
This allows direct sending from one android to another.
See here for an example
Google Cloud Messaging is what your are after:
http://developer.android.com/google/gcm/index.html
One disadvantage over your current method is that you will probably need a server to act as a broker, as a GCM message can only have a relatively small payload
I am sending an SMS to multiple numbers. When I choose only one, it works, and the message is being sent immediately. But when I use multiple (3 for example) SMS Intent is opened, but after I click Send button I see "Sending..." message all the time, SMS is not sent.
Intent sms = new Intent(Intent.ACTION_VIEW);
sms.setType("vnd.android-dir/mms-sms");
sms.putExtra("address", getSMSNumbers);
sms.putExtra("sms_body", "Help!!!");
startActivity(sms);
And getSMSNumbers String looks like this: 512991220;505202222;606123456.
What is wrong? Why isn't the message being sent and it's "sending" all the time?
Also I see when I have more than 1 number, it's being converted to MMS - why?
Maybe you could loop through the numbers and send messages one by one, like this
android.telephony.SmsManager.getDefault().
sendTextMessage("00112233", null, "Message body text", null, null);
I managed to do this - needed to turn off "Group Messaging" in AVD Settings. App was trying to send MMS and that's why it wasn't being sent.
I have created application for receieving the message from one perticular number.Its working fine.Now i want to display the alert icon on inbox application icon after receiving the message.Where should i add the code for that.
if ( extras != null ) {
// get array data from SMS
Object[] smsExtra = (Object[]) extras.get( "pdus" ); // "pdus" is the key
for ( int i = 0; i < smsExtra.length; ++i ) {
// get sms message
SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
// get content and number
String body = sms.getMessageBody();
String address = sms.getOriginatingAddress();
// create display message
if( address.equals("+91999999999")){
messages += "SMS from " + address + " :\n";
messages += body + "\n";
// notify new arriving message
Toast.makeText( context, messages, Toast.LENGTH_LONG ).show();
listSms.add(new SmsInfo(address, body));
this.abortBroadcast();
}
I am sure where you want to display alert badge/icon, but you can check and try to implement: https://github.com/jgilfelt/android-viewbadger
The icon is hardcoded in the AndroidManifest file. It is designed in this way, so the app icon can be retrieved without running any piece of code (which may result in slower startup for the app)
Some custom home applications support this, but with private APIs.
You can try to use the NotificationManager and add an icon to the status bar. That would be even more visible, which is a more recommended way of doing it. Use the status bar in such cases, for what's its designed for...
In regards to getting a dynamic icon, when the phone receives the message (push notification or whatever) and your app goes to build the notification, you can do a small http request to pull a dynamic icon file before building the notification. This will delay the posting a few seconds, but it doesn't really matter. Then you can get the resulting image and use it in the notification. The specific image can be chosen by sending some data with the (let me guess, push notification) that identifies what photo, such as a url, or an id that you can append onto an already existing url in your notification building part of the app.