Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a click-through Activity

I'm trying to adjust the brightness of my phone programmatically. I've got an Activity in my app which is translucent to do this, however users can't click through it to the activity/window beneath it. I kill this activity as soon as the brightness is set, however I want to do more work in this activity (such as gradual brightness adjustment) which requires some time, and I don't want the user tapping at their phone wondering why their actions aren't being registered.

So basically, I need to either create a mock Window which will successfully allow me to adjust screen brightness without being displayed, or work out how to make an Activity click-through. I'm not sure how to do either.

BTW, this is the code making the brightness adjustments in the Activity:

android.provider.Settings.System.putInt(getContentResolver(),
            android.provider.Settings.System.SCREEN_BRIGHTNESS, Math.round(SOME_BRIGHTNESS * 255f));

Window window = getWindow(); 
window.getAttributes().screenBrightness = SOME_BRIGHTNESS;
window.setAttributes(window.getAttributes());

float sysBrightPer = getSystemBrightness(getApplicationContext());   

new Thread() {
    public void run() {
         try {
             sleep(BRIGHT_TIMEOUT);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         finish();
    }
}.start();  

Any advice?

P.S. I found this app on the market. I wonder if the way this has been achieved would help me? https://market.android.com/details?id=com.haxor

like image 816
Glitch Avatar asked Jul 08 '11 17:07

Glitch


1 Answers

Hah! That app did help me, if only because it led me to this solution! Brightness Screen Filter

For the click lazy, use this:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);  
like image 157
Glitch Avatar answered Oct 03 '22 20:10

Glitch