Im makes an application like truecaller and wants to implement a pop-up action on its own screen. Everything is in order, but when the device is locked for pin protection activity, it immediately disappears under the call screen. Here is my code:
public class IcomingCallActivity extends Activity {
WindowManager.LayoutParams wlp;
private int scrennHeight;
@Bind(R.id.phoneTextView) TextView phoneTextView;
@Bind(R.id.nameTextView) TextView nameTextView;
@Bind(R.id.avatarImageView) CircleImageView avatarImageView;
@Bind(R.id.spamTextView) TextView spamTextView;
@Bind(R.id.container) FrameLayout container;
private ActivityManager mActivityManager;
private boolean mDismissed = false;
private static final int MSG_ID_CHECK_TOP_ACTIVITY = 1;
private static final long DELAY_INTERVAL = 100;
private String number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
setContentView(R.layout.activity_incoming_call);
ButterKnife.bind(this);
scrennHeight = getDisplayHeight();
initiallizeScreen();
final View view = getWindow().getDecorView().findViewById(R.id.container);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
lp.topMargin = (int) event.getRawY();
wlp = getWindow().getAttributes();
wlp.y = lp.topMargin - scrennHeight / 2;
getWindow().setAttributes(wlp);
break;
case MotionEvent.ACTION_UP:
SharedPreferencesSaver.get().saveCallDialogPosition((int) event.getRawY());
break;
}
return true;
}
});
}
The activity style is Dialog, but when I try to install it, because the full-screen window has a black background and the native call screen is not visible
source
share