I want that both dialog and incoming call screen be clickable. I have tried different solutions from this site, but some works in some condtions and others don't. I want to create an app like true caller, I have called an activity from BroadcastReceiver
. My code works perfectly when the screen is not locked because the incoming screen is not full screen. But when the screen is full screen the dialog activity appears for few milliseconds over the calling screen and then goes behind the calling screen.
Here is my code of my activity which I called from BroadcastReceiver
public class IncomingCallActivity extends AppCompatActivity {
private static final int MSG_ID_CHECK_TOP_ACTIVITY = 1;
private String userName;
private String TAG = IncomingCallActivity.class.getSimpleName();
private Window wind;
private PowerManager powerManager;
private PowerManager.WakeLock wakeLock;
/*private ActivityManager mActivityManager;
private boolean mDismissed = false;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wind = this.getWindow();
wind.requestFeature(Window.FEATURE_NO_TITLE);
wind.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
wind.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
wind.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
wind.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");
wakeLock.acquire();
setContentView(R.layout.activity_incoming_call);
userName = getIntent().getStringExtra(IncomingCallReceiver.NAME_KEY);
final TextView textView = (TextView) findViewById(R.id.tvUsername);
textView.setText(userName);
final ImageView ivCancel = (ImageView) findViewById(R.id.ivCancel);
ivCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wakeLock.release();
IncomingCallActivity.this.finish();
}
});
}
}