call on a telephone number
Minggu, 21 Oktober 2012
0
komentar
This post is describing that how to make a call from the Android phone using Intent.ACTION_CALL.
Start a activity with as follows and pass your telephone number
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + <your tel number>));
activity.startActivity(callIntent);
To check the state of the phone call and actions setup a call listener as follows
private class EndCallListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if(TelephonyManager.CALL_STATE_RINGING == state) {
Log.i("contactus", "RINGING, number: " + incomingNumber);
}
if(TelephonyManager.CALL_STATE_OFFHOOK == state) {
Log.i("contactus", "OFFHOOK");
}
if(TelephonyManager.CALL_STATE_IDLE == state) {
if (incomingNumber.equals(szListentelNumber) == true) {
Intent i = activity.getBaseContext().getPackageManager()
.getLaunchIntentForPackage(
activity.getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(i);
}
Log.i("contactus", "IDLE" + incomingNumber);
}
}
}
public void setUpCallListener(String szTelNumber) {
this.szListentelNumber = szTelNumber;
EndCallListener callListener = new EndCallListener();
TelephonyManager mTM = (TelephonyManager)activity.getSystemService(Context.TELEPHONY_SERVICE);
mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);
}
Enjoy the coding with Android and if you like this simple post please provide your feedback.
Thanks
Creative Android Apps
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: call on a telephone number
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://apk-xda.blogspot.com/2012/10/call-on-telephone-number.html. Terima kasih sudah singgah membaca artikel ini.Ditulis oleh Unknown
Rating Blog 5 dari 5
0 komentar:
Posting Komentar