Keeping count of the number of SMS's sent in Android - android

I want to track the number of messages that are sent from an android phone. I'm aware that there is a Broadcast message whenever a SMS is received but there is no particular event for a sent message.
I don't wanna end up counting the number of messages that appear in the "sent" area cos if I delete a sent message, the count will get changed.

Two possible solutions:
You could read the sent messages folder on a schedule, and only count the messages with time stamps that were sent between the last time you checked and the current time you're checking.
You could send the sms yourself (assuming the user is willing to go through your application to do it), then through your pending intent you could easily tell yourself when this was done.
Personally, I like possible solution #1, thought there is the problem that some SMS applications don't even store the sms in the default content provider: content://sms/sent, or like you said, the user might delete the message too quickly before it can even be counted that first time. Unfortunately, I don't think there is a better solution at this time than an hybrid solution of the two solutions I'm proposing, and even that one offers no guarantee that you won't miss some messages.

You can handle this when you send message.
Store the count in the shared preference.
When SMS is sent, increment the value in the shared preference.

Related

GCM Messages not Syncronized

I have created an app that send messages between devices using GCM , the thing is
if i want to send several messages in a row its possible that one of the sent messages wont be sent instantly and will be delayed.
My scenario is : I have tried to send 3 messages in a row , i received the first and the third one but couldn't receive the second one !!
One day after I received the second message , how could this be possible ?
Is there any way to sync the sending ? and why it took the second message 24 hours to be received ?
Google is very clear about how you get no guarantee that a message will arrive at all.
In other words, don't depend on messages getting delivered. Your system needs to be robust enough to handle this. Perhaps periodically check. Definitely check if the backend has stored messages you did not receive yet.
If you purely rely on GCM delivering your (chat?) messages, then users will very quickly uninstall your app, because it will be faulty.

SMS Messages not sent if there are more than 30 in 30 minutes

I've made a small app from where user can send SMS to many users at the same time. I've done it like it is done i all tutorials and it's working fine. I create a SMSManager, divide a message and send it as a multipart:
ArrayList<String> msgArray=smsManager.divideMessage(msg);
smsManager.sendMultipartTextMessage(phoneNo, null, msgArray, null, null);
Everything works fine. The problem is if user wants to send more than 30 messages in a couple of minutes. In that case Android displays a warning:
"{MyAppName} is sending to many messages. Do you want to allow sending messages?"
For each messages above 30 sent messages, I receive that warning. It gives me an option to allow or to deny. The problem is that even if I click 'allow', messages don't get sent.
Imagine a situation where user chooses 35 contacts and want to send a message to all of them. After he clicks send, 30 messages are sent and for other 5 that dialog is displayed where user is asked does he want to allow further sending.
Even if I click 'allow', message doesn't get sent and only 30 messages are sent. This way user gets an impression that all messages are sent but they are not. Those 5 messages are not sent even if he allowed app to send them.
Is there a workaround for this problem? I need some workaround to find out which messages are not sent and the way to send them.
Thank you.
You shouldn't set null on ArrayList sentIntents argument but add actual array of PendingIntent - you can use that to check if your message was sended correctly. Take a look at documentation.
Probably answer to this question also will be helpful.

How to send data to particular user?

I am working on application were i need to send some data to specific user without much of delay.
Actualy I have more then 1000 users who are online out of those I want to select one user and send the data to him only.
I had two solution
1.current implementation=>
So far I am using push notification for this purpose I get the user's device Id and send notification to him but problem is push notification(sending/receiving) depend on my server and GCM
server so it get delayed sometime(I observed sometime it gets delayed by 5 min also).
2.Not implemented=>
Another option is to run thread continuously to check any msg is arrived, if arrived check if whether is meant for same user or not,if he is targeted user then show the data else discard .But here also problem is even if this msg dose not belong to that user one need to check the condition and then discard.

Is it possible to know : Did recipient receive my data SMS message

I'm working on a small application which use data SMS messages.
I know how to manage thé errors during the sending.
I sent several data sms to my contact but I don't know how to know if my data SMS have arrived or not
Can you help me?
When you call SMSManager.sendTextMessage the deliveryIntent parameter tells you whether it was received. This does no mean that the user actually saw it, it just means his network received the text. It may not have been sent to his phone, or it may have been and the user didn't notice the text. There is no way to tell that the user actually looked at it.

Listen for certain incoming SMSes

Is it possible to have an app listen for all incoming SMSes and take some action on certain ones?
I read through as many of the similar questions as I could but ended up more confused.
Basically, what I want to do is this:
Every time a new SMS is received, the app checks either the sender or the text, and if a certain string is found shows a message on the screen (Toast, for example).
The app doesn't have a GUI, and if possible I would like to to be running all the time in the background.
If possible, I would also like any SMSes that are shown this way to be deleted before they reach the inbox (or automatically deleted just after).
So, is this at all doable?
Yes this is very possible. With the implementation of a BroadcastListener you could easily be able to determine when an SMS is received by registering the listener to listen to that broadcast. Then in that broadcast receiver code you implement a check for the text of the message. Then do a string compare with what you are looking for and then execute a function.
However; deleting the message from the inbox.. may take a bit of research, i'm not absolutely sure if its possible to delete SMSes programatically, but it wouldn't surprise me if it is included in the API, although, I've never seen it.

Categories

Resources