How to detect a call Drop in android

南笙酒味 提交于 2019-12-20 01:49:07

问题


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.


回答1:


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; 

    } 

} 


来源:https://stackoverflow.com/questions/34670312/how-to-detect-a-call-drop-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!