I can't seem to find a good class / API that can tell me when my phone is making a phone call. I know that I can detect when a phone call is being received by using TelephonyManager, but how do I detect if the user is calling someone?
Below is the code I have currently:
public class hiWorld extends Activity {
private int counter=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if(tm.getCallState()==1) //ringing
{
setContentView(R.layout.activity_hi_world);
TextView tcounter = (TextView)findViewById(R.id.textbox1);
tcounter.setText("calling");
}
else if (tm.getCallState()==0) //idle
{
setContentView(R.layout.activity_hi_world);
TextView tcounter = (TextView)findViewById(R.id.textbox1);
tcounter.setText("not calling");
}