override android call screen and buttons almost working

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Nov 6, 2015 8:48:35 AM via Website

Hello. I am trying to over ride the android incoming call screen. I have succeeded so far with the following code. `

enter code here

BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {

public boolean viewCreated = false;
public WindowManager wm=null;
public LinearLayout ly = null;
@Override

        public void onReceive (Context mContext, Intent intent)
        {


            android.widget.Toast.makeText(mContext, "!!!!!!!!!!!!!!!!!!!!!!!!!!11", android.widget.Toast.LENGTH_SHORT).show();

            try {

                if(wm==null) {

                    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

                        if (!viewCreated) {


                            wm = ((WindowManager) getApplicationContext().getSystemService(Service.WINDOW_SERVICE));
                            //ly = new LinearLayout(mContext);

                            WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);

                            if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                                Toast.makeText(mContext, "Phone Is Ringing", Toast.LENGTH_LONG).show();


                                //   Intent intent1 = new Intent(mContext, incomingcallscreeen.class);


                                mContext1=mContext;

                                params.height = WindowManager.LayoutParams.MATCH_PARENT;
                                params.width = WindowManager.LayoutParams.MATCH_PARENT;
                                params.format = PixelFormat.TRANSPARENT;
                                params.gravity = Gravity.TOP;


                                final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                               // ly = (LinearLayout) inflater.inflate(R.layout.incomingcallscreen, null);

                            WindowManager.LayoutParams params1 = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);
                            params1.height = WindowManager.LayoutParams.MATCH_PARENT;
                            params1.width = WindowManager.LayoutParams.MATCH_PARENT;
                            params1.format = PixelFormat.TRANSPARENT;
                            params1.gravity = Gravity.TOP;

                            ly = (LinearLayout) inflater.inflate(R.layout.incomingcallscreen, null);


               ly.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {

                            Toast.makeText(mContext1, "clicked!!!", Toast.LENGTH_LONG).show();
                        }
                    });







        }


    };

`

I can get my incoming call screen to show up, but I cant hook up any onclick events to any of the buttons or even just the plain layout. When I try it doesn't even error nothing happens. Thanks bye.