Last active
December 26, 2015 12:49
-
-
Save fiskurgit/7153526 to your computer and use it in GitHub Desktop.
Utility to fix 'stuck pixels'/burn-in when Android is set to keep the screen on when debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fiskur.screenburnfix; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.app.Activity; | |
import android.graphics.Color; | |
import android.view.View; | |
import android.view.Window; | |
import android.view.WindowManager; | |
import android.widget.LinearLayout; | |
public class BurnFixActivity extends Activity { | |
private LinearLayout mBurnFixlayout; | |
private Handler mBurnFixHandler = new Handler(); | |
private static final int SHOWTIME = 750; | |
private int mColorIndex = 0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
this.requestWindowFeature(Window.FEATURE_NO_TITLE); | |
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); | |
setContentView(R.layout.activity_burn_fix); | |
mBurnFixlayout = (LinearLayout) findViewById(R.id.burnfix_layout); | |
mBurnFixHandler.postDelayed(burnFixRunnable, SHOWTIME); | |
} | |
private Runnable burnFixRunnable = new Runnable() { | |
@Override | |
public void run() { | |
switch (mColorIndex) { | |
case 0: | |
// red | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#ff0000")); | |
break; | |
case 1: | |
// blue | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#00ff00")); | |
break; | |
case 2: | |
// green | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#0000ff")); | |
break; | |
case 3: | |
// white | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#ffffff")); | |
break; | |
case 4: | |
// red | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#ff0000")); | |
break; | |
case 5: | |
// blue | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#00ff00")); | |
break; | |
case 6: | |
// green | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#0000ff")); | |
break; | |
case 7: | |
// white | |
mBurnFixlayout.setBackgroundColor(Color.parseColor("#ffffff")); | |
break; | |
case 8: | |
// done | |
finish(); | |
break; | |
} | |
mColorIndex++; | |
mBurnFixHandler.postDelayed(this, SHOWTIME); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment