2012-02-07 1 views
2

나는 아래 코드를 사용합니다. SecurityException, StatusBarManagerService : 사용자 10049도 현재 프로세스도 android.permission.STATUS_BAR을 가지고 있지 않습니다. <uses-permission android:name="android.permission.STATUS_BAR">을 추가했지만 작동하지 않습니까? 누구든지이 문제를 해결하는 방법을 알고 있습니까? 감사합니다안드로이드에서 상태 표시 줄을 비활성화하는 방법

mStatusBar = getSystemService("statusbar"); 

if (mStatusBar != null){ 
    Log.v("statusbar", "get status bar service "+mStatusBar.getClass()); 
    Method[] arrayOfMethods; 
    Method localMethod; 
    arrayOfMethods = mStatusBar.getClass().getMethods(); 
    for (int i = 0; i < arrayOfMethods.length; i++){ 
     localMethod = arrayOfMethods[i]; 
     Log.v("statusbar", "find status bar method "+localMethod); 
     if (localMethod.getName().equalsIgnoreCase("collapse")){ 
//     mStatusBarCollapseMethod = localMethod; 
      } else if (localMethod.getName().equals("disable")){ 
       try { 
        Log.v("statusbar", "invoke "+mStatusBar+"."+localMethod.getName()+"(1)"); 
        localMethod.invoke(mStatusBar, 1); 
        Log.v("statusbar", "disable statusbar"); 
       } catch (Exception e) { 
        Log.v("statusbar", "disable statusbar excption:"+e.toString()); 
        e.printStackTrace(); 
       } 
      } 
     } 
    } 
} 
+0

답변 : http://stackoverflow.com/a/10380535/788848 – PoOk

답변

3

을 당신이 당신의 자바 코드에서 상태 표시 줄을 사용 중지해야하는 경우, 당신은이 작업을 수행 할 수 있습니다

Window win = getWindow(); 
win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
2

간단한 솔루션, 단지 예를 들어, 매니페스트에 android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”을 추가

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="de.vogella.android.temperature" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".Convert" 
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
    <uses-sdk android:minSdkVersion="9" /> 

</manifest> 
+0

나는 전체 화면 테마를 설정했습니다. 하지만 내가 전화 할 때 public void onAttachedToWindow() { if (!mInPreviewBoolean){ this.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);//for capture the home key } super.onAttachedToWindow(); } 상태 표시 줄이 보이고 내 구현이 잠금 화면 활동이므로 전체 화면으로 상태 표시 줄이 보이지 않거나 비활성화되도록하고 싶습니다. 권한을 android.permission.EXPAND_STATUS_BAR 추가 한 다음 statusbar.collapse() 액세스 할 수 있지만 심지어 추가 할 android.permission.STA –

+0

이 여전히 위쪽 베젤에서 아래로 스 와이프 때 알림에 액세스 할 수 있습니다. –