4

I'm writing an app that runs on background during a telephone conversation and logs the coordinates to a file after the conversation has end,I know Android telephony API can detect a call manual disconnect by user*(correct me,if I'm wrong)*,

But what I want is to know whether the service disconnection have caused due to call drop,is there a way or an API I can use to achieve this,

All what I need is to programmatically differentiate a disconnected call and a dropped call.

Please help.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ashif-ismail
  • 1,037
  • 17
  • 34

1 Answers1

3

Try this code, but I am not sure..

private getCallFailedString(Call call) { 

    Phone phone = PhoneApp.getInstance().phone; 
    Connection c = call.getEarliestConnection(); 

    Connection.DisconnectCause cause = c.getDisconnectCause(); 

    switch (cause) { 
        case BUSY: 
        break; 

    case CONGESTION: 
         break; 

    case LOST_SIGNAL: 
         break; 

    case LIMIT_EXCEEDED: 
         break; 

    case POWER_OFF: 
         break; 

    case SIM_ERROR: 
         break; 

    case OUT_OF_SERVICE: 
         break; 

    default: 
         break; 

    } 

} 
Mayank Patel
  • 3,868
  • 10
  • 36
  • 59
jobin
  • 1,489
  • 5
  • 27
  • 52
  • 1
    Will this cover call drop event...is there a threshold signal strength below which call drop happens...?what if we write a service that fires during all calls and monitors the signal strength,so if fluctuation fall below threshold we infer that call drop has happened... – ashif-ismail Jan 08 '16 at 08:43
  • This is a part of Android internal telephony API and is not easily accessible. I don't know if Java Reflection will work in this case. Please check this link: http://www.programcreek.com/java-api-examples/index.php?class=com.android.internal.telephony.Call&method=getEarliestConnection – Vinit Shandilya May 16 '16 at 20:23
  • That could would not work the main way to do it requires your app to be a system app, so you'd need a OEM key. – yams Dec 20 '21 at 21:57