private static void convertActivityToTranslucentAfterL ( Activity activity ) { try { Method getActivityOptions = Activity . class . getDeclaredMethod ( "getActivityOptions" ) ; getActivityOptions . setAccessible ( true ) ; Object options = getActivityOptions . invoke ( activity ) ; Class < ? > [ ] classes = Activity . class . getDeclaredClasses ( ) ; Class < ? > translucentConversionListenerClazz = null ; for ( Class clazz : classes ) { if ( clazz . getSimpleName ( ) . contains ( "TranslucentConversionListener" ) ) { translucentConversionListenerClazz = clazz ; } } Method convertToTranslucent = Activity . class . getDeclaredMethod ( "convertToTranslucent" , translucentConversionListenerClazz , ActivityOptions . class ) ; convertToTranslucent . setAccessible ( true ) ; convertToTranslucent . invoke ( activity , null , options ) ; } catch ( Throwable t ) { } }
Calling the convertToTranslucent method on platforms after Android 5 . 0