Android編程之內(nèi)存溢出解決方案(OOM)實(shí)例總結(jié)
本文實(shí)例總結(jié)了Android編程之內(nèi)存溢出解決方案(OOM)。分享給大家供大家參考,具體如下:
在最近做的工程中發(fā)現(xiàn)加載的圖片太多或圖片過大時(shí)經(jīng)常出現(xiàn)OOM問題,找網(wǎng)上資料也提供了很多方法,但自己感覺有點(diǎn)亂,特此,今天在不同型號(hào)的三款安卓手機(jī)上做了測(cè)試,因?yàn)橛行Ч灿薪Y(jié)果,今天小馬就做個(gè)詳細(xì)的總結(jié),以供朋友們共同交流學(xué)習(xí),也供自己以后在解決OOM問題上有所提高,提前講下,片幅有點(diǎn)長,涉及的東西太多,大家耐心看,肯定有收獲的,里面的很多東西小馬也是學(xué)習(xí)參考網(wǎng)絡(luò)資料使用的,先來簡(jiǎn)單講下下:
一般我們大家在遇到內(nèi)存問題的時(shí)候常用的方式網(wǎng)上也有相關(guān)資料,大體如下幾種:
一:在內(nèi)存引用上做些處理,常用的有軟引用、強(qiáng)化引用、弱引用
二:在內(nèi)存中加載圖片時(shí)直接在內(nèi)存中做處理,如:邊界壓縮
三:動(dòng)態(tài)回收內(nèi)存
四:優(yōu)化Dalvik虛擬機(jī)的堆內(nèi)存分配
五:自定義堆內(nèi)存大小
可是真的有這么簡(jiǎn)單嗎,就用以上方式就能解決OOM了?不是的,繼續(xù)來看...
下面小馬就照著上面的次序來整理下解決的幾種方式,數(shù)字序號(hào)與上面對(duì)應(yīng):
1:軟引用(SoftReference)、虛引用(PhantomRefrence)、弱引用(WeakReference),這三個(gè)類是對(duì)heap中java對(duì)象的應(yīng)用,通過這個(gè)三個(gè)類可以和gc做簡(jiǎn)單的交互,除了這三個(gè)以外還有一個(gè)是最常用的強(qiáng)引用
1.1:強(qiáng)引用,例如下面代碼:
Object o=new Object(); Object o1=o;
上面代碼中第一句是在heap堆中創(chuàng)建新的Object對(duì)象通過o引用這個(gè)對(duì)象,第二句是通過o建立o1到new Object()這個(gè)heap堆中的對(duì)象的引用,這兩個(gè)引用都是強(qiáng)引用.只要存在對(duì)heap中對(duì)象的引用,gc就不會(huì)收集該對(duì)象.如果通過如下代碼:
o=null; o1=null
heap中對(duì)象有強(qiáng)可及對(duì)象、軟可及對(duì)象、弱可及對(duì)象、虛可及對(duì)象和不可到達(dá)對(duì)象。應(yīng)用的強(qiáng)弱順序是強(qiáng)、軟、弱、和虛。對(duì)于對(duì)象是屬于哪種可及的對(duì)象,由他的最強(qiáng)的引用決定。如下:
String abc=new String("abc"); //1 SoftReference<String> abcSoftRef=new SoftReference<String>(abc); //2 WeakReference<String> abcWeakRef = new WeakReference<String>(abc); //3 abc=null; //4 abcSoftRef.clear();//5
上面的代碼中:
第一行在heap對(duì)中創(chuàng)建內(nèi)容為“abc”的對(duì)象,并建立abc到該對(duì)象的強(qiáng)引用,該對(duì)象是強(qiáng)可及的。第二行和第三行分別建立對(duì)heap中對(duì)象的軟引用和弱引用,此時(shí)heap中的對(duì)象仍是強(qiáng)可及的。第四行之后heap中對(duì)象不再是強(qiáng)可及的,變成軟可及的。同樣第五行執(zhí)行之后變成弱可及的。
1.2:軟引用
軟引用是主要用于內(nèi)存敏感的高速緩存。在jvm報(bào)告內(nèi)存不足之前會(huì)清除所有的軟引用,這樣以來gc就有可能收集軟可及的對(duì)象,可能解決內(nèi)存吃緊問題,避免內(nèi)存溢出。什么時(shí)候會(huì)被收集取決于gc的算法和gc運(yùn)行時(shí)可用內(nèi)存的大小。當(dāng)gc決定要收集軟引用是執(zhí)行以下過程,以上面的abcSoftRef為例:
1 首先將abcSoftRef的referent設(shè)置為null,不再引用heap中的new String("abc")對(duì)象。
2 將heap中的new String("abc")對(duì)象設(shè)置為可結(jié)束的(finalizable)。
3 當(dāng)heap中的new String("abc")對(duì)象的finalize()方法被運(yùn)行而且該對(duì)象占用的內(nèi)存被釋放, abcSoftRef被添加到它的ReferenceQueue中。
注:對(duì)ReferenceQueue軟引用和弱引用可以有可無,但是虛引用必須有,參見:
Reference(T paramT, ReferenceQueue<? super T>paramReferenceQueue)
被 Soft Reference 指到的對(duì)象,即使沒有任何 Direct Reference,也不會(huì)被清除。一直要到 JVM 內(nèi)存不足且 沒有 Direct Reference 時(shí)才會(huì)清除,SoftReference 是用來設(shè)計(jì) object-cache 之用的。如此一來 SoftReference 不但可以把對(duì)象 cache 起來,也不會(huì)造成內(nèi)存不足的錯(cuò)誤 (OutOfMemoryError)。我覺得 Soft Reference 也適合拿來實(shí)作 pooling 的技巧。
A obj = new A(); Refenrence sr = new SoftReference(obj); //引用時(shí) if(sr!=null){ obj = sr.get(); }else{ obj = new A(); sr = new SoftReference(obj); }
1.3:弱引用
當(dāng)gc碰到弱可及對(duì)象,并釋放abcWeakRef的引用,收集該對(duì)象。但是gc可能需要對(duì)此運(yùn)用才能找到該弱可及對(duì)象。通過如下代碼可以了明了的看出它的作用:
String abc=new String("abc"); WeakReference<String> abcWeakRef = new WeakReference<String>(abc); abc=null; System.out.println("before gc: "+abcWeakRef.get()); System.gc(); System.out.println("after gc: "+abcWeakRef.get());
運(yùn)行結(jié)果:
before gc: abc
after gc: null
gc收集弱可及對(duì)象的執(zhí)行過程和軟可及一樣,只是gc不會(huì)根據(jù)內(nèi)存情況來決定是不是收集該對(duì)象。如果你希望能隨時(shí)取得某對(duì)象的信息,但又不想影響此對(duì)象的垃圾收集,那么你應(yīng)該用 Weak Reference 來記住此對(duì)象,而不是用一般的 reference。
A obj = new A(); WeakReference wr = new WeakReference(obj); obj = null; //等待一段時(shí)間,obj對(duì)象就會(huì)被垃圾回收 ... if (wr.get()==null) { System.out.println("obj 已經(jīng)被清除了 "); } else { System.out.println("obj 尚未被清除,其信息是 "+obj.toString()); } ... }
在此例中,透過 get() 可以取得此 Reference 的所指到的對(duì)象,如果返回值為 null 的話,代表此對(duì)象已經(jīng)被清除。這類的技巧,在設(shè)計(jì) Optimizer 或 Debugger 這類的程序時(shí)常會(huì)用到,因?yàn)檫@類程序需要取得某對(duì)象的信息,但是不可以 影響此對(duì)象的垃圾收集。
1.4:虛引用
就是沒有的意思,建立虛引用之后通過get方法返回結(jié)果始終為null,通過源代碼你會(huì)發(fā)現(xiàn),虛引用通向會(huì)把引用的對(duì)象寫進(jìn)referent,只是get方法返回結(jié)果為null.先看一下和gc交互的過程在說一下他的作用.
1.4.1 不把referent設(shè)置為null, 直接把heap中的new String("abc")對(duì)象設(shè)置為可結(jié)束的(finalizable).
1.4.2 與軟引用和弱引用不同, 先把PhantomRefrence對(duì)象添加到它的ReferenceQueue中.然后在釋放虛可及的對(duì)象.
你會(huì)發(fā)現(xiàn)在收集heap中的new String("abc")對(duì)象之前,你就可以做一些其他的事情.通過以下代碼可以了解他的作用.
import java.lang.ref.PhantomReference; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.reflect.Field; public class Test { public static boolean isRun = true; public static void main(String[] args) throws Exception { String abc = new String("abc"); System.out.println(abc.getClass() + "@" + abc.hashCode()); final ReferenceQueue referenceQueue = new ReferenceQueue<String>(); new Thread() { public void run() { while (isRun) { Object o = referenceQueue.poll(); if (o != null) { try { Field rereferent = Reference.class .getDeclaredField("referent"); rereferent.setAccessible(true); Object result = rereferent.get(o); System.out.println("gc will collect:" + result.getClass() + "@" + result.hashCode()); } catch (Exception e) { e.printStackTrace(); } } } } }.start(); PhantomReference<String> abcWeakRef = new PhantomReference<String>(abc, referenceQueue); abc = null; Thread.currentThread().sleep(3000); System.gc(); Thread.currentThread().sleep(3000); isRun = false; } }
結(jié)果為
class java.lang.String@96354
gc will collect:class java.lang.String@96354
好了,關(guān)于引用就講到這,下面看2
2:在內(nèi)存中壓縮小馬做了下測(cè)試,對(duì)于少量不太大的圖片這種方式可行,但太多而又大的圖片小馬用個(gè)笨的方式就是,先在內(nèi)存中壓縮,再用軟引用避免OOM,兩種方式代碼如下,大家可參考下:
方式一代碼如下:
@SuppressWarnings("unused") private Bitmap copressImage(String imgPath){ File picture = new File(imgPath); Options bitmapFactoryOptions = new BitmapFactory.Options(); //下面這個(gè)設(shè)置是將圖片邊界不可調(diào)節(jié)變?yōu)榭烧{(diào)節(jié) bitmapFactoryOptions.inJustDecodeBounds = true; bitmapFactoryOptions.inSampleSize = 2; int outWidth = bitmapFactoryOptions.outWidth; int outHeight = bitmapFactoryOptions.outHeight; bmap = BitmapFactory.decodeFile(picture.getAbsolutePath(), bitmapFactoryOptions); float imagew = 150; float imageh = 150; int yRatio = (int) Math.ceil(bitmapFactoryOptions.outHeight / imageh); int xRatio = (int) Math .ceil(bitmapFactoryOptions.outWidth / imagew); if (yRatio > 1 || xRatio > 1) { if (yRatio > xRatio) { bitmapFactoryOptions.inSampleSize = yRatio; } else { bitmapFactoryOptions.inSampleSize = xRatio; } } bitmapFactoryOptions.inJustDecodeBounds = false; bmap = BitmapFactory.decodeFile(picture.getAbsolutePath(), bitmapFactoryOptions); if(bmap != null){ //ivwCouponImage.setImageBitmap(bmap); return bmap; } return null; }
方式二代碼如下:
package com.lvguo.scanstreet.activity; import java.io.File; import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import com.lvguo.scanstreet.R; import com.lvguo.scanstreet.data.ApplicationData; /** * @Title: PhotoScanActivity.java * @Description: 照片預(yù)覽控制類 * @author XiaoMa */ public class PhotoScanActivity extends Activity { private Gallery gallery ; private List<String> ImageList; private List<String> it ; private ImageAdapter adapter ; private String path ; private String shopType; private HashMap<String, SoftReference<Bitmap>> imageCache = null; private Bitmap bitmap = null; private SoftReference<Bitmap> srf = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.photoscan); Intent intent = this.getIntent(); if(intent != null){ if(intent.getBundleExtra("bundle") != null){ Bundle bundle = intent.getBundleExtra("bundle"); path = bundle.getString("path"); shopType = bundle.getString("shopType"); } } init(); } private void init(){ imageCache = new HashMap<String, SoftReference<Bitmap>>(); gallery = (Gallery)findViewById(R.id.gallery); ImageList = getSD(); if(ImageList.size() == 0){ Toast.makeText(getApplicationContext(), "無照片,請(qǐng)返回拍照后再使用預(yù)覽", Toast.LENGTH_SHORT).show(); return ; } adapter = new ImageAdapter(this, ImageList); gallery.setAdapter(adapter); gallery.setOnItemLongClickListener(longlistener); } /** * Gallery長按事件操作實(shí)現(xiàn) */ private OnItemLongClickListener longlistener = new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { //此處添加長按事件刪除照片實(shí)現(xiàn) AlertDialog.Builder dialog = new AlertDialog.Builder(PhotoScanActivity.this); dialog.setIcon(R.drawable.warn); dialog.setTitle("刪除提示"); dialog.setMessage("你確定要?jiǎng)h除這張照片嗎?"); dialog.setPositiveButton("確定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { File file = new File(it.get(position)); boolean isSuccess; if(file.exists()){ isSuccess = file.delete(); if(isSuccess){ ImageList.remove(position); adapter.notifyDataSetChanged(); //gallery.setAdapter(adapter); if(ImageList.size() == 0){ Toast.makeText(getApplicationContext(), getResources().getString(R.string.phoSizeZero), Toast.LENGTH_SHORT).show(); } Toast.makeText(getApplicationContext(), getResources().getString(R.string.phoDelSuccess), Toast.LENGTH_SHORT).show(); } } } }); dialog.setNegativeButton("取消",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.create().show(); return false; } }; /** * 獲取SD卡上的所有圖片文件 * @return */ private List<String> getSD() { /* 設(shè)定目前所在路徑 */ File fileK ; it = new ArrayList<String>(); if("newadd".equals(shopType)){ //如果是從查看本人新增列表項(xiàng)或商戶列表項(xiàng)進(jìn)來時(shí) fileK = new File(ApplicationData.TEMP); }else{ //此時(shí)為純粹新增 fileK = new File(path); } File[] files = fileK.listFiles(); if(files != null && files.length>0){ for(File f : files ){ if(getImageFile(f.getName())){ it.add(f.getPath()); Options bitmapFactoryOptions = new BitmapFactory.Options(); //下面這個(gè)設(shè)置是將圖片邊界不可調(diào)節(jié)變?yōu)榭烧{(diào)節(jié) bitmapFactoryOptions.inJustDecodeBounds = true; bitmapFactoryOptions.inSampleSize = 5; int outWidth = bitmapFactoryOptions.outWidth; int outHeight = bitmapFactoryOptions.outHeight; float imagew = 150; float imageh = 150; int yRatio = (int) Math.ceil(bitmapFactoryOptions.outHeight / imageh); int xRatio = (int) Math .ceil(bitmapFactoryOptions.outWidth / imagew); if (yRatio > 1 || xRatio > 1) { if (yRatio > xRatio) { bitmapFactoryOptions.inSampleSize = yRatio; } else { bitmapFactoryOptions.inSampleSize = xRatio; } } bitmapFactoryOptions.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeFile(f.getPath(), bitmapFactoryOptions); //bitmap = BitmapFactory.decodeFile(f.getPath()); srf = new SoftReference<Bitmap>(bitmap); imageCache.put(f.getName(), srf); } } } return it; } /** * 獲取圖片文件方法的具體實(shí)現(xiàn) * @param fName * @return */ private boolean getImageFile(String fName) { boolean re; /* 取得擴(kuò)展名 */ String end = fName .substring(fName.lastIndexOf(".") + 1, fName.length()) .toLowerCase(); /* 按擴(kuò)展名的類型決定MimeType */ if (end.equals("jpg") || end.equals("gif") || end.equals("png") || end.equals("jpeg") || end.equals("bmp")) { re = true; } else { re = false; } return re; } public class ImageAdapter extends BaseAdapter{ /* 聲明變量 */ int mGalleryItemBackground; private Context mContext; private List<String> lis; /* ImageAdapter的構(gòu)造符 */ public ImageAdapter(Context c, List<String> li) { mContext = c; lis = li; TypedArray a = obtainStyledAttributes(R.styleable.Gallery); mGalleryItemBackground = a.getResourceId(R.styleable.Gallery_android_galleryItemBackground, 0); a.recycle(); } /* 幾定要重寫的方法getCount,傳回圖片數(shù)目 */ public int getCount() { return lis.size(); } /* 一定要重寫的方法getItem,傳回position */ public Object getItem(int position) { return lis.get(position); } /* 一定要重寫的方法getItemId,傳并position */ public long getItemId(int position) { return position; } /* 幾定要重寫的方法getView,傳并幾View對(duì)象 */ public View getView(int position, View convertView, ViewGroup parent) { System.out.println("lis:"+lis); File file = new File(it.get(position)); SoftReference<Bitmap> srf = imageCache.get(file.getName()); Bitmap bit = srf.get(); ImageView i = new ImageView(mContext); i.setImageBitmap(bit); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setLayoutParams( new Gallery.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT)); return i; } } }
上面兩種方式第一種直接使用邊界壓縮,第二種在使用邊界壓縮的情況下間接的使用了軟引用來避免OOM,但大家都知道,這些函數(shù)在完成decode后,最終都是通過java層的createBitmap來完成的,需要消耗更多內(nèi)存,如果圖片多且大,這種方式還是會(huì)引用OOM異常的,不著急,有的是辦法解決,繼續(xù)看,以下方式也大有妙用的:
1.
InputStream is = this.getResources().openRawResource(R.drawable.pic1); BitmapFactory.Options options=new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inSampleSize = 10; //width,hight設(shè)為原來的十分一 Bitmap btp =BitmapFactory.decodeStream(is,null,options);
2.
if(!bmp.isRecycle() ){ bmp.recycle() //回收?qǐng)D片所占的內(nèi)存 system.gc() //提醒系統(tǒng)及時(shí)回收 }
上面代碼與下面代碼大家可分開使用,也可有效緩解內(nèi)存問題哦...吼吼...
/** 這個(gè)地方大家別搞混了,為了方便小馬把兩個(gè)貼一起了,使用的時(shí)候記得分開使用 * 以最省內(nèi)存的方式讀取本地資源的圖片 */ public static Bitmap readBitMap(Context context, int resId){ BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.RGB_565; opt.inPurgeable = true; opt.inInputShareable = true; //獲取資源圖片 InputStream is = context.getResources().openRawResource(resId); return BitmapFactory.decodeStream(is,null,opt); }
3:大家可以選擇在合適的地方使用以下代碼動(dòng)態(tài)并自行顯式調(diào)用GC來回收內(nèi)存:
if(bitmapObject.isRecycled()==false) //如果沒有回收 bitmapObject.recycle();
4:這個(gè)就好玩了,優(yōu)化Dalvik虛擬機(jī)的堆內(nèi)存分配,聽著很強(qiáng)大,來看下具體是怎么一回事
對(duì)于Android平臺(tái)來說,其托管層使用的Dalvik JavaVM從目前的表現(xiàn)來看還有很多地方可以優(yōu)化處理,比如我們?cè)陂_發(fā)一些大型游戲或耗資源的應(yīng)用中可能考慮手動(dòng)干涉GC處理,使用 dalvik.system.VMRuntime類提供的setTargetHeapUtilization方法可以增強(qiáng)程序堆內(nèi)存的處理效率。當(dāng)然具體原理我們可以參考開源工程,這里我們僅說下使用方法: 代碼如下:
在程序onCreate時(shí)就可以調(diào)用
即可
5:自定義我們的應(yīng)用需要多大的內(nèi)存,這個(gè)好暴力哇,強(qiáng)行設(shè)置最小內(nèi)存大小,代碼如下:
private final static int CWJ_HEAP_SIZE = 6* 1024* 1024 ; //設(shè)置最小heap內(nèi)存為6MB大小 VMRuntime.getRuntime().setMinimumHeapSize(CWJ_HEAP_SIZE);
好了,文章寫完了,片幅有點(diǎn)長,因?yàn)樯婕暗降臇|西太多了,其它文章小馬都會(huì)貼源碼,這篇文章小馬是直接在項(xiàng)目中用三款安卓真機(jī)測(cè)試的,有效果,項(xiàng)目原碼就不在這貼了,不然泄密了都,吼吼,但這里講下還是會(huì)因?yàn)槭謾C(jī)的不同而不同,大家得根據(jù)自己需求選擇合適的方式來避免OOM,大家加油呀,每天都有或多或少的收獲,這也算是進(jìn)步,加油加油!
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
Android連接MySQL數(shù)據(jù)庫詳細(xì)教程
在Android應(yīng)用程序中連接 MySQL 數(shù)據(jù)庫可以幫助開發(fā)人員實(shí)現(xiàn)更豐富的數(shù)據(jù)管理功能,本教程將介紹如何在Android應(yīng)用程序中使用低版本的MySQL Connector/J驅(qū)動(dòng)程序來連接MySQL數(shù)據(jù)庫,需要的朋友可以參考下2023-05-05Android App支付系列(一):微信支付接入詳細(xì)指南(附官方支付demo)
這篇文章主要介紹了Android App支付系列(一):微信支付接入詳細(xì)指南(附官方支付demo) ,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11Android應(yīng)用APP自動(dòng)更新功能的代碼實(shí)現(xiàn)
本篇文章主要介紹了Android應(yīng)用APP自動(dòng)更新功能的代碼實(shí)現(xiàn),想要實(shí)現(xiàn)這個(gè)效果的同學(xué)可以了解一下。2016-11-11Android自定義wheelview實(shí)現(xiàn)滾動(dòng)日期選擇器
這篇文章主要為大家詳細(xì)介紹了Android自定義wheelview實(shí)現(xiàn)滾動(dòng)日期選擇器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07一文帶你搞清楚Android游戲發(fā)行切包資源ID那點(diǎn)事
這篇文章主要介紹了Android 解決游戲發(fā)行切包資源ID的一些問題,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2023-05-05Android模擬器安裝APP出現(xiàn)INSTALL_FAILED_NO_MATCHING_ABIS錯(cuò)誤解決方案
這篇文章主要介紹了 Android模擬器安裝APP出現(xiàn)INSTALL_FAILED_NO_MATCHING_ABIS錯(cuò)誤解決方案的相關(guān)資料,需要的朋友可以參考下2016-12-12Android中Intent組件的入門學(xué)習(xí)心得
Intent組件雖然不是四大組件,但卻是連接四大組件的橋梁,學(xué)習(xí)好這個(gè)知識(shí),也非常的重要,下面這篇文章主要給大家介紹了關(guān)于Android中Intent組件的相關(guān)資料,需要的朋友可以參考下2021-12-12Android使用AutoCompleteTextView實(shí)現(xiàn)自動(dòng)填充功能的案例
今天小編就為大家分享一篇關(guān)于Android使用AutoCompleteTextView實(shí)現(xiàn)自動(dòng)填充功能的案例,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-03-03Flutter實(shí)現(xiàn)底部和頂部導(dǎo)航欄
這篇文章主要為大家詳細(xì)介紹了Flutter實(shí)現(xiàn)底部和頂部導(dǎo)航欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07Android 判斷網(wǎng)絡(luò)狀態(tài)及開啟網(wǎng)路
這篇文章主要介紹了Android 判斷網(wǎng)絡(luò)狀態(tài)及開啟網(wǎng)路的相關(guān)資料,在開發(fā)網(wǎng)路狀態(tài)的時(shí)候需要先判斷是否開啟之后在提示用戶進(jìn)行開啟操作,需要的朋友可以參考下2017-08-08