Note that there are some explanatory texts on larger screens.

plurals
  1. POError using StatusBarManagerService - java.lang.SecurityException on android.permission.STATUS_BAR_SERVICE
    text
    copied!<p>I wanted to use the StatusBarManagerService, but it's not available on the SDK, so I tried "cheating", using reflection to access it.</p> <p>I was able to access it, but now it's giving me an error when accessing one of its methods:</p> <pre><code>java.lang.SecurityException: StatusBarManagerService: Neither user 10139 nor current process has android.permission.STATUS_BAR_SERVICE. </code></pre> <p>Is it possible to be granted this permission, or is it simply not possible?</p> <p>This is my code:</p> <pre><code> try { Class serviceManagerClass = Class.forName("android.os.ServiceManager"); Method getService = serviceManagerClass.getMethod("getService", String.class); IBinder retbinder = (IBinder) getService.invoke(serviceManagerClass, "statusbar"); Class statusBarClass = Class.forName(retbinder.getInterfaceDescriptor()); Object statusBarObject = statusBarClass.getClasses()[0].getMethod("asInterface", IBinder.class).invoke(null, new Object[] { retbinder }); Method clearAll = statusBarClass.getMethod("onClearAllNotifications"); clearAll.setAccessible(true); clearAll.invoke(statusBarObject); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>And this is what I added in the AndroidManifest:</p> <pre><code> &lt;uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /&gt; </code></pre> <p>Is it possible to be granted this permission, or is it simply not possible?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload