4

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?

user1392021
  • 99
  • 1
  • 5
  • what you're trying to achieve is a bit more difficult than you're thinking it is. however, if this is something you can check online there's probably a way to do this with an HTTP client – thepoosh May 13 '12 at 10:07
  • 1
    I don't think its really viable. At least not in a simple way. Since what you're doing, even if you call it with an intent from you app, doesn't return any "result" as far as I know – Juan Cortés May 13 '12 at 10:18
  • Calling seems to be the easiest part , but how to really handle the USSD response ? I don't think that there is an API for ussd yet .check this : http://code.google.com/p/android/issues/detail?id=1285 – moujib May 13 '12 at 10:28
  • Nmd. I get it. These aren't your users. But I'm still confused as to why you need to save user's data in a DB? If I'm using your app to see how much I have on my account, I certainly don't expect you to save this data for whatever you plan to use it for... – o_O Aug 21 '12 at 22:26

1 Answers1

3

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:

Community
  • 1
  • 1
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281