電話がいつ電話をかけているかを教えてくれる良いクラス/APIが見つからないようです。TelephonyManager を使用して電話の着信を検出できることはわかっていますが、ユーザーが誰かに電話をかけているかどうかを検出するにはどうすればよいでしょうか?
以下は私が現在持っているコードです:
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");
}