要去掉android4.0上的状态栏,全屏显示的代码如下: 
 
1、将usleep和killall这二个文件放到assets文件夹下。这二个文件可在下面的附件中下载到。 
 
2、创建Device.java(注:附件里有完整的代码): 
 
   | 001 | importjava.io.BufferedInputStream; | 
    | 002 | importjava.io.BufferedReader; | 
    | 003 | importjava.io.DataOutputStream; | 
     | 005 | importjava.io.FileNotFoundException; | 
    | 006 | importjava.io.FileOutputStream; | 
    | 007 | importjava.io.IOException; | 
    | 008 | importjava.io.InputStream; | 
    | 009 | importjava.io.InputStreamReader; | 
    | 010 | importjava.util.ArrayList; | 
      | 013 | importandroid.content.Context; | 
    | 014 | importandroid.content.res.AssetManager; | 
    | 015 | importandroid.util.Log; | 
          | 022 |     privatestaticString TAG = Device.class.getSimpleName(); | 
     | 024 |     privatebooleanmHasRootBeenChecked = false; | 
    | 025 |     privatebooleanmIsDeviceRooted = false; | 
     | 027 |     privatebooleanmHasBeenInitialized = false; | 
    | 028 |     privateContext mAppContext = null; | 
     | 030 |     privatebooleanmSystembarVisible = true; | 
     | 032 |     staticpublicvoid initialize(Context appContext) { | 
    | 033 |         if(INSTANCE.mHasBeenInitialized == true) { | 
    | 034 |             Log.e(TAG, "Initializing already initialized class " + TAG); | 
     | 036 |         INSTANCE.mHasBeenInitialized = true; | 
    | 037 |         INSTANCE.mAppContext = appContext; | 
    | 038 |         AddKillAll(appContext, "killall"); | 
    | 039 |         AddKillAll(appContext, "usleep"); | 
      | 042 |     privatestaticvoid AddKillAll(Context appContext, String commandFileName) { | 
    | 043 |         File killAllFile = newFile("/system/xbin/"+commandFileName); | 
    | 044 |         if(!killAllFile.exists()) { | 
    | 045 |             AssetManager assetManager = appContext.getAssets(); | 
    | 046 |             InputStream inputStream = null; | 
    | 047 |             String commandFilePath = null; | 
     | 049 |                 inputStream = assetManager.open(commandFileName); | 
    | 050 |                 commandFilePath = appContext.getApplicationContext().getFilesDir() | 
    | 051 |                         .getAbsolutePath() + File.separator + commandFileName; | 
    | 052 |                 saveToFile(commandFilePath, inputStream); | 
    | 053 |             } catch(IOException e) { | 
    | 054 |                 Log.e("tag", e.toString()); | 
       | 058 |                 p = Runtime.getRuntime().exec("su"); | 
    | 059 |                 DataOutputStream os = newDataOutputStream(p.getOutputStream()); | 
    | 060 |                 os.writeBytes("mount -o remount,rw /dev/block/stl6 /system\n"); | 
    | 061 |                 os.writeBytes("cd system/xbin\n"); | 
    | 062 |                 os.writeBytes("cat "+ commandFilePath + " > " + commandFileName + "\n"); | 
    | 063 |                 os.writeBytes("chmod 755 "+ commandFileName + "\n"); | 
    | 064 |                 os.writeBytes("mount -o remount,ro /dev/block/stl6 /system\n"); | 
    | 065 |                 os.writeBytes("exit\n"); | 
      | 068 |             } catch(Exception e) { | 
    | 069 |                 Log.e(TAG, e.toString()); | 
        | 074 |     staticpublicDevice getInstance() { | 
    | 075 |         INSTANCE.checkInitialized(); | 
       | 079 |     privatevoidcheckInitialized() { | 
    | 080 |         if(mHasBeenInitialized == false) | 
    | 081 |             thrownewIllegalStateException("Singleton class "+ TAG | 
    | 082 |                     + " is not yet initialized"); | 
      | 085 |     publicbooleanisRooted() { | 
        | 090 |         if(mHasRootBeenChecked) { | 
    | 091 |             returnmIsDeviceRooted; | 
       | 095 |             File file = newFile("/system/app/Superuser.apk"); | 
     | 097 |                 mHasRootBeenChecked = true; | 
    | 098 |                 mIsDeviceRooted = true; | 
      | 101 |         } catch(Exception e) { | 
        | 106 |             ArrayList<String> envlist = newArrayList<String>(); | 
    | 107 |             Map<String, String> env = System.getenv(); | 
    | 108 |             for(String envName : env.keySet()) { | 
    | 109 |                 envlist.add(envName + "="+ env.get(envName)); | 
     | 111 |             String[] envp = (String[]) envlist.toArray(newString[0]); | 
    | 112 |             Process proc = Runtime.getRuntime() | 
    | 113 |                     .exec(newString[] { "which", "su"}, envp); | 
    | 114 |             BufferedReader in = newBufferedReader(newInputStreamReader( | 
    | 115 |                     proc.getInputStream())); | 
    | 116 |             if(in.readLine() != null) { | 
    | 117 |                 mHasRootBeenChecked = true; | 
    | 118 |                 mIsDeviceRooted = true; | 
      | 121 |         } catch(Exception e) { | 
       | 125 |         mHasRootBeenChecked = true; | 
    | 126 |         mIsDeviceRooted = false; | 
        | 131 |     publicenumAndroidVersion { | 
       | 135 |     publicAndroidVersion getAndroidVersion() { | 
     | 137 |         intsdk = android.os.Build.VERSION.SDK_INT; | 
    | 138 |         if(11<= sdk && sdk <= 13) { | 
    | 139 |             returnAndroidVersion.HC; | 
    | 140 |         } elseif (14<= sdk && sdk <= 15) { | 
    | 141 |             returnAndroidVersion.ICS; | 
    | 142 |         } elseif (16== sdk) { | 
    | 143 |             returnAndroidVersion.JB; | 
     | 145 |             returnAndroidVersion.UNKNOWN; | 
       | 149 |     publicvoidshowSystembar(booleanmakeVisible) { | 
      | 152 |             ArrayList<String> envlist = newArrayList<String>(); | 
    | 153 |             Map<String, String> env = System.getenv(); | 
    | 154 |             for(String envName : env.keySet()) { | 
    | 155 |                 envlist.add(envName + "="+ env.get(envName)); | 
     | 157 |             String[] envp = (String[]) envlist.toArray(newString[0]); | 
      | 160 |                 Device dev = Device.getInstance(); | 
    | 161 |                 if(dev.getAndroidVersion() == AndroidVersion.HC) { | 
    | 162 |                     command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService"; | 
     | 164 |                     command = "rm /sdcard/hidebar-lock\n" | 
     | 166 |                             + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService"; | 
     | 168 |                 Runtime.getRuntime().exec(newString[] { "su", "-c", command }, envp); | 
    | 169 |                 mSystembarVisible = true; | 
      | 172 |                 Device dev = Device.getInstance(); | 
    | 173 |                 if(dev.getAndroidVersion() == AndroidVersion.HC) { | 
    | 174 |                     command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib service call activity 79 s16 com.android.systemui"; | 
     | 176 |                     command = "touch /sdcard/hidebar-lock\n" | 
    | 177 |                             + "while [ -f /sdcard/hidebar-lock ]\n" | 
     | 179 |                             + "killall com.android.systemui\n" | 
      | 182 |                             + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService"; | 
     | 184 |                 Runtime.getRuntime().exec(newString[] { "su", "-c", command }, envp); | 
    | 185 |                 mSystembarVisible = false; | 
     | 187 |         } catch(Exception e) { | 
        | 192 |     publicbooleanisSystembarVisible() { | 
     | 194 |         returnmSystembarVisible; | 
      | 197 |     publicvoidsendBackEvent() { | 
     | 199 |             ArrayList<String> envlist = newArrayList<String>(); | 
    | 200 |             Map<String, String> env = System.getenv(); | 
    | 201 |             for(String envName : env.keySet()) { | 
    | 202 |                 envlist.add(envName + "="+ env.get(envName)); | 
     | 204 |             String[] envp = (String[]) envlist.toArray(newString[0]); | 
    | 205 |             Runtime.getRuntime().exec( | 
    | 206 |                     newString[] { "su", "-c", | 
    | 207 |                             "LD_LIBRARY_PATH=/vendor/lib:/system/lib input keyevent 4"}, | 
     | 209 |         } catch(Exception e) { | 
        | 214 |     publicstaticvoid saveToFile(String filePath, InputStream in){ | 
    | 215 |         FileOutputStream fos = null; | 
    | 216 |         BufferedInputStream bis = null; | 
    | 217 |         intBUFFER_SIZE = 1024; | 
    | 218 |         byte[] buf = newbyte[BUFFER_SIZE]; | 
     | 220 |         bis = newBufferedInputStream(in); | 
     | 222 |             fos = newFileOutputStream(filePath); | 
    | 223 |             while((size = bis.read(buf)) != -1) | 
    | 224 |                 fos.write(buf, 0, size); | 
    | 225 |         } catch(FileNotFoundException e) { | 
     | 227 |         } catch(IOException e) { | 
             | 237 |             } catch(IOException e) { | 
           
  
3、然后在加载acitivity或你想全屏的activity中,加入以下代码: 
 
 
 | 2 | Device.initialize(getApplicationContext()); | 
 
  
 | 3 | Device device = Device.getInstance(); | 
 
  
| 4 | device.showSystembar(false); |