privatevoidrecreateReactContextInBackground(JavaScriptExecutorjsExecutor,JSBundleLoaderjsBundleLoader){UiThreadUtil.assertOnUiThread();ReactContextInitParamsinitParams=newReactContextInitParams(jsExecutor,jsBundleLoader);if(!mIsContextInitAsyncTaskRunning){// No background task to create react context is currently running, create and execute one.ReactContextInitAsyncTaskinitTask=newReactContextInitAsyncTask();initTask.execute(initParams);mIsContextInitAsyncTaskRunning=true;}else{// Background task is currently running, queue up most recent init params to recreate context// once task completes.mPendingReactContextInitParams=initParams;}}

packagecom.react.smart.utils;importandroid.content.Context;importandroid.content.res.AssetManager;importandroid.util.Log;importjava.io.*;/**
* Created by sky on 16/9/19.
*/publicclassFileAssetUtils{publicstaticvoidcopyAssets(Contextcontext,Stringsrc,Stringdist){AssetManagerassetManager=context.getAssets();String[]files=null;try{files=assetManager.list(src);}catch(IOExceptione){Log.e("tag","Failed to get asset file list.",e);}for(Stringfilename:files){InputStreamin=null;OutputStreamout=null;try{in=assetManager.open(src+File.separator+filename);FileoutFile=newFile(dist+File.separator+src,filename);out=newFileOutputStream(outFile);copyFile(in,out);in.close();in=null;out.flush();out.close();out=null;}catch(IOExceptione){Log.e("tag","Failed to copy asset file: "+filename,e);}}}publicstaticvoidcopyFile(InputStreamin,OutputStreamout)throwsIOException{byte[]buffer=newbyte[1024];intread;while((read=in.read(buffer))!=-1){out.write(buffer,0,read);}}}