Android make call activity to check prepaid phone balance - android

I would like to make an activity where i can call a certain numer to check my prepaid phone balance.
In my provider its for example *555# then i will get a response like for example "Your remaining phone credit is 5 USD". I would like to use this data (5 USD) to save in the database.
I am just a beginner, does someone know how to proceed?

You could issue a CALL intent (which requires a permission) and use a broadcast receiver to listen for the SMS response (again, permission required).
However, this isn't a very robust solution as you have to check the SMS sender id and the message text, whcih may change in the future.
EDIT
As pointed out in comments, you will need to use the USSD protocol for this. It definitely appears possible, as there is an app that does just that: https://play.google.com/store/apps/details?id=com.iba.ussdchecker&hl=en.
These threads may be helpful:
Call (and get the response for) a USSD Code, in the background?
How to run USSD commands on android?
How is it possible to do USSD requests on Android?

Related

Modifing SMS before sending in android

I was wondering if it's possible to modify the SMS before sending it in Android, but not only if it's send by my application, but also if it's being send by other applications. My application would work in the background and wait for an sms sending, and when that occurres it prevents it from doing so, modifies it and sends it.
For example, a default SMS application(built-in or otherwise) sends an sms to someone and I want to catch it before it does, modify the body(like add new receiver or some text inside message itself).
I think that this: Can I modify sms_body before sending SMS with built-in SMS Application? might be an answer to my question, but I'm not sure, and it's kind of old.
Let me know if I was unclear in something. Thanks.
Let me try with simple example-
Its just like you have an Account in a Bank and you wish all deposit should come in your Account. Here Account refers to your App and Bank refers to your Mobile device.
In a short, you can't achieve this on a non-rooted device. Yes that is possible on non-rooted device if user like to send his messages from your App, then surely you can modify messages written by user.
not only if it's send by my application, but also if it's being send by other applications
This is not possible, except perhaps on rooted devices.

Are there things like an Android trigger

I have never developed something in Android before, but now my company has put me on a project which includes android.
My question is this: Is it possible to write an application that runs in the background and waits for triggers (if that is the correct word for it). For instance lets say I want my application to do something as soon as you open your emails or as soon as you get an email. Is there some API that I can use to interact with other applications such as Mail. The application does not have to have any GUI, it will literally just push some information notifications on the mail just received or opened.
I don't require a to technical answer, but rather just yes or no, and indeed yes, where can I get more info on it. Also if it is not possible, is there some workaround to achieve this. I have googled it, but most of the links are how to send an email from your application.
Thanks
EDIT: So it can even be triggered when a notification is received. Then I just want to look at the notification and determine if it is an email?
You could register BroadCastReceiver for the actions that you need to be caught

Receive specific SMS and elaborate it with an Android app?

sorry fo my complete ignorance developing an Android.
I'm asking about the feaseability of this pseudocode I would like to implement as native app; let imagine a task that:
when a specific SMS arrive (only those sent from a specific sender number)
possibly (multi-SMS in case of text bigger than 160 chars )
elaborate/format each received SMS:
. save text content on a local db
. print text on a bluetooth printer
. reply to sender with some sort of "ACK" SMS
BTW, what above could be sort of background task, and I would need on foreground a sort of user interface that visualizes received SMS and do some user actions (sending back SMS to sender)
Is all that possible on Android ? Any issue ?
I mean, above all: is possible to "catch" specific SMSs (by example those sent by a specific sender number), living unalterated the usual SMS workflow for ALL other SMSs ?
Sorry for my beginner question and Thanks for your patience
giorgio
www.giorgiorobino.com
Following this link to implement a BroadcastReceiver that will listen for incoming SMS.
Inside your onReceive from your BroadcastReceiver, handle your logic (print/save/..)
It is possible, yes. But not recommended. That being said the way to set this up is to catch the SMS intent, so your app would be started when an SMS is received. Otherwise it would not run at all (as long as you don't have any other interface open). For a code example on the message interception part, see this post. For the database part look up local storage on android phones. Look up on SMS messaging for the reply. Not sure how bluetooth printing would work as I've never done it, but if it's a standard protocol I'm sure there's either built in support or a library for it.

capture the Sms exactly before being sent

I’m trying to develop an application to do some manipulation (compression and security matters) on the outgoing Sms regardless of the composer application. The main challenge is that I cannot capture the Sms exactly before being sent. For instance the user compose the message body using Go Sms Pro and when the send button is pressed , right before the sms is actually sent we capture it and do the compression and security matters on .
Any solution or replacement idea appreciated.
Starting with KitKat, the SMS content provider has been opened up (finally): http://developer.android.com/about/versions/android-4.4.html
To make this work with previous versions of android, you could set up a content observer to watch content://sms/, query the appropriate tables in that database, and then do whatever you like to erase the message before it goes out. This is just a thought mind you, but whatever you do will likely involve using this method.
This is not possible, short of via your own custom build of the Android OS. You have no ability to intercept, let alone modify, the calls from an arbitrary app via SmsManager to the OS to send an SMS message.

Is there anything like GCM for offline communication?

Seems like GCM for Android only works if there is internet. Wondering whether there are any other methods (maybe via text/call, etc) that could trigger a background service which would send back user's location (via text, etc. or maybe keep it until connection is present)?
My two concerns are:
How much can I do without the user doing anything (or even knowing it's happening... assuming they downloaded the app already and gave appropriate permissions)?
How would I send the data back? (if via text, Reason #1 seems to be a bigger matter)
Here is an alternate solution but it is costly,
Create Broradcast Receiver that listen for incoming SMS.
In any sms with start some predefined word like "START_SERVICE" is arrived then fire the broadcast and start the service you want.
You may use normal SMS scheme or any bulk sms kind of service.
The above scenario doesn't require any INTERNET connection at all.

Categories

Resources