Convert a translucent themed Activity android.R.attr#windowIsTranslucent to a fullscreen opaque Activity. - Android User Interface

Android examples for User Interface:Screen Full

Description

Convert a translucent themed Activity android.R.attr#windowIsTranslucent to a fullscreen opaque Activity.

Demo Code


//package com.java2s;
import android.app.Activity;
import java.lang.reflect.Method;

public class Main {
    /**//w w w  .  ja v a2 s  .co m
     * Convert a translucent themed Activity
     * {@link android.R.attr#windowIsTranslucent} to a fullscreen opaque
     * Activity.
     * <p>
     * Call this whenever the background of a translucent Activity has changed
     * to become opaque. Doing so will allow the {@link android.view.Surface} of
     * the Activity behind to be released.
     * <p>
     * This call has no effect on non-translucent activities or on activities
     * with the {@link android.R.attr#windowIsFloating} attribute.
     */
    public static void convertActivityFromTranslucent(Activity activity) {
        try {
            Method method = Activity.class
                    .getDeclaredMethod("convertFromTranslucent");
            method.setAccessible(true);
            method.invoke(activity);
        } catch (Throwable t) {
        }
    }
}

Related Tutorials