Back to project page BrokenDisplay.
The source code is released under:
Apache License
If you think the Android project BrokenDisplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.foolish.brokendisplay; /*from ww w .j a v a 2 s . c o m*/ import android.app.Service; import android.content.Intent; import android.graphics.PixelFormat; import android.os.IBinder; import android.view.Gravity; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; import android.widget.ImageView.ScaleType; public class BrokenGlassService extends Service { private WindowManager windowManager; private MyImageView overlay; public static boolean IsRunning; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); IsRunning = true; windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); overlay = new MyImageView(this); overlay.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); overlay.setImageResource(OverviewFragment.IMAGE_RESOURCE); WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); overlay.setScaleType(ScaleType.FIT_XY); params.gravity = Gravity.TOP | Gravity.LEFT; params.x = 0; params.y = 0; windowManager.addView(overlay, params); } @Override public void onDestroy() { super.onDestroy(); IsRunning = false; if (overlay != null) windowManager.removeView(overlay); } }