I tried to call in background in my app on button click but it is not working on android 4.3 . I dont want any caller screen just my application activity should be shown when call to a phone is done in background.
Code is given below...
*try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + "8800806074"));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
telephonyManager.listen(phoneListener,
PhoneStateListener.LISTEN_CALL_STATE);
}
}, 10000);*
.............
private class PhoneCallListener extends PhoneStateListener {
boolean flag = true;
String LOG_TAG = "Call TEST";
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
Log.i(LOG_TAG, "number: " + incomingNumber);
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
Log.i(LOG_TAG, "OFFHOOK");
// invoking activity
if (flag) {
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(
getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
System.out.println("flagged retrieving app");
flag = false;
}
}
if (TelephonyManager.CALL_STATE_IDLE == state) {
Log.i(LOG_TAG, "IDLE");
Log.i(LOG_TAG, "restart app");
}
}
}
0 comments:
Post a Comment