日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android4.0.3去掉底部状态栏statusbar,全屏显示示例代码

發布時間:2023/12/10 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android4.0.3去掉底部状态栏statusbar,全屏显示示例代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

要去掉android4.0上的狀態欄,全屏顯示的代碼如下:

1、將usleep和killall這二個文件放到assets文件夾下。這二個文件可在下面的附件中下載到。

2、創建Device.java(注:附件里有完整的代碼):

001import java.io.BufferedInputStream;
002import java.io.BufferedReader;
003import java.io.DataOutputStream;
004import java.io.File;
005import java.io.FileNotFoundException;
006import java.io.FileOutputStream;
007import java.io.IOException;
008import java.io.InputStream;
009import java.io.InputStreamReader;
010import java.util.ArrayList;
011import java.util.Map;
012?
013import android.content.Context;
014import android.content.res.AssetManager;
015import android.util.Log;
016?
017?
018public enum Device {
019?
020????INSTANCE;
021?
022????private static String TAG = Device.class.getSimpleName();
023?
024????private boolean mHasRootBeenChecked = false;
025????private boolean mIsDeviceRooted = false;
026?
027????private boolean mHasBeenInitialized = false;
028????private Context mAppContext = null;
029?
030????private boolean mSystembarVisible = true;
031?
032????static public void initialize(Context appContext) {
033????????if (INSTANCE.mHasBeenInitialized == true) {
034????????????Log.e(TAG, "Initializing already initialized class " + TAG);
035????????}
036????????INSTANCE.mHasBeenInitialized = true;
037????????INSTANCE.mAppContext = appContext;
038????????AddKillAll(appContext, "killall");
039????????AddKillAll(appContext, "usleep");
040????}
041?
042????private static void AddKillAll(Context appContext, String commandFileName) {
043????????File killAllFile = new File("/system/xbin/"+commandFileName);
044????????if (!killAllFile.exists()) {
045????????????AssetManager assetManager = appContext.getAssets();
046????????????InputStream inputStream = null;
047????????????String commandFilePath = null;
048????????????try {
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());
055????????????}
056????????????try {
057????????????????Process p;
058????????????????p = Runtime.getRuntime().exec("su");
059????????????????DataOutputStream os = new DataOutputStream(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");
066????????????????os.flush();
067????????????????p.waitFor();
068????????????} catch (Exception e) {
069????????????????Log.e(TAG, e.toString());
070????????????}
071????????}
072????}
073?
074????static public Device getInstance() {
075????????INSTANCE.checkInitialized();
076????????return INSTANCE;
077????}
078?
079????private void checkInitialized() {
080????????if (mHasBeenInitialized == false)
081????????????throw new IllegalStateException("Singleton class " + TAG
082????????????????????+ " is not yet initialized");
083????}
084?
085????public boolean isRooted() {
086?
087????????checkInitialized();
088?
089?
090????????if (mHasRootBeenChecked) {
091????????????return mIsDeviceRooted;
092????????}
093?
094????????try {
095????????????File file = new File("/system/app/Superuser.apk");
096????????????if (file.exists()) {
097????????????????mHasRootBeenChecked = true;
098????????????????mIsDeviceRooted = true;
099????????????????return true;
100????????????}
101????????} catch (Exception e) {
102????????????e.printStackTrace();
103????????}
104?
105????????try {
106????????????ArrayList<String> envlist = new ArrayList<String>();
107????????????Map<String, String> env = System.getenv();
108????????????for (String envName : env.keySet()) {
109????????????????envlist.add(envName + "=" + env.get(envName));
110????????????}
111????????????String[] envp = (String[]) envlist.toArray(new String[0]);
112????????????Process proc = Runtime.getRuntime()
113????????????????????.exec(new String[] { "which", "su" }, envp);
114????????????BufferedReader in = new BufferedReader(new InputStreamReader(
115????????????????????proc.getInputStream()));
116????????????if (in.readLine() != null) {
117????????????????mHasRootBeenChecked = true;
118????????????????mIsDeviceRooted = true;
119????????????????return true;
120????????????}
121????????} catch (Exception e) {
122????????????e.printStackTrace();
123????????}
124?
125????????mHasRootBeenChecked = true;
126????????mIsDeviceRooted = false;
127????????return false;
128?
129????}
130?
131????public enum AndroidVersion {
132????????HC, ICS, JB, UNKNOWN
133????};
134?
135????public AndroidVersion getAndroidVersion() {
136????????checkInitialized();
137????????int sdk = android.os.Build.VERSION.SDK_INT;
138????????if (11 <= sdk && sdk <= 13) {
139????????????return AndroidVersion.HC;
140????????} else if (14 <= sdk && sdk <= 15) {
141????????????return AndroidVersion.ICS;
142????????} else if (16 == sdk) {
143????????????return AndroidVersion.JB;
144????????} else {
145????????????return AndroidVersion.UNKNOWN;
146????????}
147????}
148?
149????public void showSystembar(boolean makeVisible) {
150????????checkInitialized();
151????????try {
152????????????ArrayList<String> envlist = new ArrayList<String>();
153????????????Map<String, String> env = System.getenv();
154????????????for (String envName : env.keySet()) {
155????????????????envlist.add(envName + "=" + env.get(envName));
156????????????}
157????????????String[] envp = (String[]) envlist.toArray(new String[0]);
158????????????if (makeVisible) {
159????????????????String command;
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";
163????????????????} else {
164????????????????????command = "rm /sdcard/hidebar-lock\n"
165????????????????????????????+ "sleep 5\n"
166????????????????????????????+ "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";
167????????????????}
168????????????????Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);
169????????????????mSystembarVisible = true;
170????????????} else {
171????????????????String command;
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";
175????????????????} else {
176????????????????????command = "touch /sdcard/hidebar-lock\n"
177????????????????????????????+ "while [ -f /sdcard/hidebar-lock ]\n"
178????????????????????????????+ "do\n"
179????????????????????????????+ "killall com.android.systemui\n"
180????????????????????????????+ "usleep 500000\n"
181????????????????????????????+ "done\n"
182????????????????????????????+ "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";
183????????????????}
184????????????????Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);
185????????????????mSystembarVisible = false;
186????????????}
187????????} catch (Exception e) {
188????????????e.printStackTrace();
189????????}
190????}
191?
192????public boolean isSystembarVisible() {
193????????checkInitialized();
194????????return mSystembarVisible;
195????}
196?
197????public void sendBackEvent() {
198????????try {
199????????????ArrayList<String> envlist = new ArrayList<String>();
200????????????Map<String, String> env = System.getenv();
201????????????for (String envName : env.keySet()) {
202????????????????envlist.add(envName + "=" + env.get(envName));
203????????????}
204????????????String[] envp = (String[]) envlist.toArray(new String[0]);
205????????????Runtime.getRuntime().exec(
206????????????????????new String[] { "su", "-c",
207????????????????????????????"LD_LIBRARY_PATH=/vendor/lib:/system/lib input keyevent 4" },
208????????????????????envp);
209????????} catch (Exception e) {
210????????????e.printStackTrace();
211????????}
212????}
213?????
214????public static void saveToFile(String filePath, InputStream in){
215????????FileOutputStream fos = null;
216????????BufferedInputStream bis = null;
217????????int BUFFER_SIZE = 1024;
218????????byte[] buf = new byte[BUFFER_SIZE];
219????????int size = 0;
220????????bis = new BufferedInputStream(in);
221????????try {
222????????????fos = new FileOutputStream(filePath);
223????????????while ((size = bis.read(buf)) != -1)
224????????????????fos.write(buf, 0, size);
225????????} catch (FileNotFoundException e) {
226????????????e.printStackTrace();
227????????} catch (IOException e) {
228????????????e.printStackTrace();
229????????} finally {
230????????????try {
231????????????????if (fos != null) {
232????????????????????fos.close();
233????????????????}
234????????????????if (bis != null) {
235????????????????????bis.close();
236????????????????}
237????????????} catch (IOException e) {
238????????????????e.printStackTrace();
239????????????}
240????????}
241????}
242?
243}

3、然后在加載acitivity或你想全屏的activity中,加入以下代碼:

1//當為true時,表示有底部狀態欄
2Device.initialize(getApplicationContext());
3Device device = Device.getInstance();
4device.showSystembar(false);

總結

以上是生活随笔為你收集整理的android4.0.3去掉底部状态栏statusbar,全屏显示示例代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。