want to display overlay (like truecaller app) while incoming call. I checked Pop up window over Android native incoming call screen like true caller Android app this link and tried to execute but it displays values in separate page..
Updates: I solved this using WindowManager but now problem is i cant remove the view i tried as follows please help me to solve this problem
public void onReceive(Context context, Intent intent) {
Log.i("", "Intent " + intent.toString());
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
String mVal;
try {
mVal = new GetCallContacts(context).execute().get();
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams params;
params = new WindowManager.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE ,
PixelFormat.TRANSPARENT);
params.gravity = Gravity.TOP;
LayoutInflater mInflater = LayoutInflater.from(context);
mView = mInflater.inflate(R.layout.activity_incoming_call, null);
TextView tv = (TextView) mView.findViewById(R.id.textView1);
tv.setText("BJP Contacts: "+mVal);
wm.addView(mView, params);
} catch (Exception e) {
Log.e(state, e.toString()) ;
}
} else if (intent.getAction().equals(BOOT_COMPLETED)) {
context.startService(intent);
} else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)
|| state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
try {
((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).removeView(mView);//wm.removeView(mView);// it does not remove view
} catch (Exception e) {
}
}
}