I created a small service, just like here:
public class ChatHeadService extends Service {
private WindowManager windowManager;
private ImageView chatHead;
@Override public IBinder onBind(Intent intent) {
// Not used
return null;
}
@Override public void onCreate() {
super.onCreate();
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
chatHead = new ImageView(this);
chatHead.setImageResource(R.drawable.android_head);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = 0;
params.y = 100;
windowManager.addView(chatHead, params);
}
@Override
public void onDestroy() {
super.onDestroy();
if (chatHead != null) windowManager.removeView(chatHead);
}
}
Only difference is that my ImageView is MATCH_PARENT on width and height, the image inside is 99% transparent.
Everything works fine, but I can not touch, swipe or anything else when the service runs. I want the ImageView to be totally hidden for any touch interaction with the user - like the ImageView is nothing else but a sticker on the glass.
I tried setClickable(true / false) and als to override onTouchEvent with returning true / false, but to no avail.
Any help here on how to accomplish this?
P.S.: I know this is no desired behavior of a serious app, but this is just meant to be a little joke app for me & my friends.