Search code examples
androidphone-number

Find out whether the ougoing call is to a phone call or a data request


I'm developing an Android app that receives the ougoing call event and extract the destination address from it, cancel the call for doing some process and then redial the same address number automatically without user intention.

The problem: I don't want to process destination numbers which are not a real destination phone address (i.e. a USSD number like *21# which make some data request on some operator). How can I find out dinamically (without maintaining any table) whether the outgoing destination is a phone call or a data request from the operator?


Solution

  • One possible approach is to check if the number matches the format of a USSD:

    A typical USSD message starts with a * followed by digits which indicate an action to be performed or are parameters. Each group of numbers is separated by a *, and the message is terminated with a #.

    USSDs have a maximum length of 182 characters.