Get the amount of sent sms - android

I'm learning android programming and to practice I want to develop a little app. The idea is to count the sent messages, like a counter...
The approach I was thinking of was doing a service that monitors the "content://sms/out" I do this by using a ContentObserver, inside the onChange method I increment some kind of counter or something like that... then from an activity I fetch the data from service (IPC)...
Is this a good way of doing this? I've been reading a lot and I couldn't make out a best way of writing this little test app...
There is no "global variable" or something like that where android stores the amount of sent messages right?? Because I couldn't find that...
Thanks for reading!!
===================================UPDATE========================================
I've been doing some research and found there are two kind of applications in the market that count the sent sms.
The first group, just read the amount of sms in the cellphone. I did the following test, I checked how many sms this app showed me, after that I deleted a message and the app showed one message less. This is not a good approach. The app that behave in this wave is this one https://market.android.com/details?id=org.kknd.android.smscounter&feature=search_result#?t=W251bGwsMSwxLDEsIm9yZy5ra25kLmFuZHJvaWQuc21zY291bnRlciJd
The second group I don't know how, counts perfectly the messages sent, I did the same test I did in the previos case and the app showed the correct number of sent and received messages... So I thought that the app must have some kind of service running all the time to check the messages... But for my surprise there is no service, so how this app work?!?!?!? The app is: https://market.android.com/details?id=nitro.phonestats&feature=search_result#?t=W251bGwsMSwxLDEsIm5pdHJvLnBob25lc3RhdHMiXQ.. (great app by the way...)
Any idea???

Related

Sending Too much messages programmatically in Android jellyBean

I'm trying to send Text messages to different contacts in a bulk. The contacts are several hundred and i'm reading them from a text file. Now when my app tries to send messages , A Dialog Appears telling
App is sending too much messages => Allow , Deny
I've studied several forums that it's a restriction introduced in JellyBean to prevent malicious activity and it can't be undone without rooting your device and running some weird scripts. Is there a fix to this problem? if there isn't any fix , then can we Programatically click Allow button on that message dialog within our app?
Thanks in advance.
Is there a fix to this problem?
Send fewer messages.
Or, send the messages at a slower rate.
Or, use some sort of online SMS gateway to send the messages, perhaps through a serve of yours, rather than sending them through Android's SmsManager. You can find some of these by searching for online sms gateway on your favorite search engine.
can we Programatically click Allow button on that message dialog within our app?
No. The point behind the block is so that the user gets a vote as to whether your app can spend quite so much money (or SMS allotment from a post-paid plan) on the user's behalf. Bulk SMS is not designed to be done from Android, but rather from an online SMS gateway.

Sending messages between Android Wear & Mobile?

I'm writing an app which sends a predefined message to a predefined number. It then gets the response and displays this to the user. I've got the mobile side working, and I am now working on the Wear app, however have become a little stuck as to how to do it.
I've managed to send the message from the Wear device by implementing a listener on the mobile app, which then triggers the activity to send a message. What I can't figure out how to do, is that the response the app gets and send it back to the Wear device.
Looking here:https://developer.android.com/training/wearables/data-layer/index.html
I have used the MessagesAPI for sending the message, however unsure what to use if I want to receive a message. Does anyone know what the best way to do this would be? My initial instinct says I'm going to have to ditch the messagesApi and use the Data one?
You should send the response the same way you used to send the first message, but this time the wearable will be listening for messages (usually in your WearableListenerService).
Take a look at this: https://github.com/heinrisch/talkclient
Either you can use the library or look at the code. I would look at the code, its quite easy to follow.
It sounds like you can use either data or message api, depending on your needs. To receive a message you either have the app active and get it though a listener, or you create a service.

Intercept incoming flash messages on android mobile

can anyone help me to intercept the incoming Flash messages (specially the ones from the telecom company, where they send our current balance after some activity like message sent).
My application deals with sending SMSes in bulk and I don't want the flash message popping now and then. So is it possible on Android ?
EDIT: Everyone says its not possible above Android 1.6 but I found a similar App on Google Play but I want the source of that kind of App. Please Help.
Edit: More than a year has passed and still I didnt got the solution. Can anyone help to resolve this thread..??
Might depend on the channel [of communication] used by your service provider. I guess they don't use SMS, probably they use WAP/PUSH or some pre-installed provider app for the notifications, which makes this harder to block. If it was SMS, you'd definitely have lots of ways to block their notifications, but in this case, I doubt there might be an easy / direct way to do this.
Flight Mode should ideally block telco / service-provider messages / notifications, but then this also blocks your connectivity, right? So, am not so certain on this one. Isn't there a way to opt-out of service provider notifications, maybe via a ussd routine? I've heard of this once...
Flash sms it is the same as usual sms except data coding flags. It has "class 0" indication in DCS.
For details about sms coding see: GSM 3.38 specification / 4 SMS Data Coding Scheme.
Some fragment from spec about it
When a mobile terminated message is class 0 and the MS has the capability of displaying short messages, the MS shall display the message immediately and send an acknowledgement to the SC when the message has successfully reached the MS irrespective of whether there is memory available in the SIM or ME. The message shall not be automatically stored in the SIM or ME.
So, in most cases, phone just displays this message and skips usual chain of actions.
Probably, you can't catch this message with usual API... probably you need deep hook and rooted device.
[Or may be just switch off this service by calling customer support?]

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.

How to send App to App message

Is there a way to send messages directly from application to application? I'm making an app that needs verification from another phone, but I only send the messages via SMS, so there is a big chance that a false message having the same format might end up being recognized by the application as a legit one.
I don't think it's possible. For functionality like this you would usually use server, and, maybe Google Cloud2Device to send Push messages.
If both phones are in close proximity to each other, you could make a bluetooth connection and transfer the data that way. It would work like that Bump app that transfers files when the phones are bumped together.
As a work around to the way you are doing it now, you could do a simple encryption of the messages so that they are not plain text and won't match a real text message. If you wanted to make it pretty, you could encode the data in a picture so it doesn't look like a garbage text to the end user.

Categories

Resources