-1

I want an imageview for my app just like fb messenger chat header which will be shown everywhere when the app is running in background and we are working on another app. I have seen some codes but they just make it visible at a fixed position not movable the code is here and i have just used textview for the time being instead of imageview.

public void onCreate() {
        super.onCreate();
        //mView = new HUDView(this);
        mButton = new Button(this);
        mButton.setText("Overlay button");
        mButton.setOnTouchListener(new OnTouchListener(){
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Toast.makeText(getApplicationContext(),"Overlay button event", Toast.LENGTH_SHORT).show();
                return false;
            }
        });
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.RIGHT | Gravity.CENTER;
        params.setTitle("Load Average");
        WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        wm.addView(mButton, params);
    }

Any help would be appreciated.

Jaura
  • 487
  • 5
  • 12

1 Answers1

0

The link of Lalit Poptani is good. You have to use a service for this kind of feature.

Please, look the example form Waza_Be, here: https://stackoverflow.com/a/15980900/5098294

Community
  • 1
  • 1
  • Thanks for your reply but this is already done by me as i have posted in my question. I have solved my issue today completely.:) – Jaura Aug 25 '15 at 08:24