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.
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 know that this may possible be a duplicate question, but the other questions don't answer mine.
I am working on an app that pulls notifications (specifically notifications for new WhatsApp messages) from the status bar and reads their content. I have managed to pull the notification title and the message content.
The problem is, when more than one unread message is received, the notification switches from using EXTRA_TEXT to EXTRA_SUMMARY_TEXT (then returning e.g. "2 new messages" instead.
It must possible to separate the messages somehow, seeing as certain existing apps do it (e.g. Snowball combines all messages and displays them in one place, showing message content even when multiple messages have been received and are still unread).
I know that users can send messages via Intents. However, I cannot seem to access incoming intents and have, therefore, assumed that WhatsApp uses explicit intents to send messages.
Intent i = new Intent("com.test.testapp.NOTIFICATION_LISTENER");
Bundle extras = sbn.getNotification().extras;
if(sbn.getPackageName().contains("com.whatsapp"))
{
String title = extras.getString(Notification.EXTRA_TITLE);
String summary = extras.getString(Notification.EXTRA_SUMMARY_TEXT);
String msg = extras.getString(Notification.EXTRA_TEXT);
if(msg != null)
{
i.putExtra("notification_event", msg);
}
else
{
i.putExtra("notification_event", summary);
}
}
else
{
i.putExtra("notification_event","...");
}
sendBroadcast(i);
My question:
How can I display all received messages without getting "2 new messages" as content OR is there a better way of doing this?
I need to access message content, the sender's number and the time that the message was received, so that I can save it to a database.
Any help would be appreciated.
WhatsApp application has structure for sending notification like this :
Case Notification
Message comes from A : Hi Title : A Text: Hi
Message comes from A : How are you Title : A Text: How are you
Title : A Text: 2 new messages
Message comes from B : Hello Title : B Text: Hello
Title : B Text: 1 new message
Title : A Text: 2 new messages
Title : WhatsApp Text: 3 new messages from 2 conversation
---- Here comes the stacking ----
Message comes from C : Good work Title : C Text: Good work
Title : C Text: 1 new message
Title : B Text: 1 new message
Title : A Text: 2 new messages
Title : WhatsApp Text: 4 new messages from 3 conversation
---- This way when new sender message comes, previoud notifications also comes and we get callback in NotificationListener ----
Last notification comes with Title as Package Name : WhatsApp and Text as : X messages from Y Conversation
To get Text :
sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TEXT).toString();
To get Title :
sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TITLE).toString();
To work with this sturcture of stacking, we need to parse this notification stack and display only selective information in our application
I hope my answer will help and solve your query
This answer is given at : enter link description here
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.
I am developing an android appliation that marks SMS messages as read when it is received. I do that using this code:
if(readMessages.contains(id)){
ContentValues values=new ContentValues();
values.put("read", 1);
values.put("seen", 1);
getContentResolver().update(Uri.parse("content://sms/inbox"),
values, "_id="+id, null);
Log.i("read message","id:"+id);
if(readThread.contains(trdid)){
ContentValues values1=new ContentValues();
values1.put("read", 1);
values1.put("seen", 1);
getContentResolver().update(Uri.parse("content://sms/inbox"),
values, "_id="+trdid, null);
Log.i("read thread","id:"+trdid);
}
}
As you can see, I've marked the thread and message id's as READ, and the message is indeed marked as read.
My question however is, why doesnt the icon on the messaging app (the red bubble showing the number of new messages) dissappear after I execute the code? Is it possible to do that?
Thank you! :)
why doesnt the icon on the messaging app (the red bubble showing the number of new messages) dissappear after I execute the code? Is it possible to do that?
You cannot control the notifications from an app that is not your own. Additionally, AOSP messaging does not have red bubble notifications, so this is some custom app.
Regardless of that though, you can't control the notification status of a third party app. It should be the responsibility of the SMS client to update its UI and notifications when a change in the SMS database takes place.
i'm using 2 Galaxy S3 and i send a message from one to the other. I want the other to send back a response like "received msg"
i'm using the android beam demo, and i want to add this ack.I send the ack message when i treat the first message in ProcessIntent with a simple "sendNdefMessage"? how do i manage the receipt of the ack in the other device?
void processIntent(Intent intent) {
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(
NfcAdapter.EXTRA_NDEF_MESSAGES);
// only one message sent during the beam
NdefMessage msg = (NdefMessage) rawMsgs[0];
// record 0 contains the MIME type, record 1 is the AAR, if present
mInfoText.setText(new String(msg.getRecords()[0].getPayload()));
//ack message
mNfcAdapter.setNdefPushMessageCallback(ackMsg, this);
}
Thanks a lot
You cannot send a message back, unfortunately. However, the device that sent the message knows when it has been received successfully. Your app can be notified of this by registering a callback with NfcAdapter.OnNdefPushCompleteCallback()