jeudi 26 avril 2018

Android statusbar class reflection

I'm trying to get this piece of code put right but the "statusbar" word gets underlined with a huge message telling me that I must use one of the following provided keywords.

Image of what I have in android studio editor: enter image description here

I want to get somehow access to the statusbarManager to disable expansion.

Is there a workaround?

Here is my code:

       try{
        Object sbservice = getSystemService( "statusbar" );
        Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
        Method showsb = statusbarManager.getMethod( "expand" );
        showsb.invoke(sbservice)
    }catch(ClassNotFoundException e)
    {e.printStackTrace();}
    catch (NoSuchMethodException e)
    {e.printStackTrace();}
    catch(IllegalAccessException e)
    {e.printStackTrace();}
    catch (InvocationTargetException e)
    {e.printStackTrace();}





Aucun commentaire:

Enregistrer un commentaire