android app啟動慢黑屏白屏的問題解決方案
阿新 • • 發佈:2018-12-19
1、處理閃屏的問題需要在valus下的styles.xml下處理
下面是路徑沒有就新建一個
主要的就是選中的那個
在AndroidManifest.xml配置一下
上面配合完成就不閃了
2、啟動太慢怎麼處理的問題
我使用的是
InitService
import android.app.IntentService; import android.content.Context; import android.content.Intent; import android.os.Build; import com.umeng.analytics.MobclickAgent; import cn.jpush.android.api.JPushInterface; /** * An {@link IntentService} subclass for handling asynchronous task requests in * a service on a separate handler thread. * <p> * <p> * app 開啟的時候 初始化 操作 減少app 開啟的效率 * TODO: Customize class - update intent actions, extra parameters and static * helper methods. */ public class InitService extends IntentService { // TODO: Rename actions, choose action names that describe tasks that this // IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS private static final String ACTION_FOO = "com.xinli.vkeeper.services.action.FOO"; /** * Instantiates a new Init service. */ public InitService() { super("InitService"); } /** * Starts this service to perform action Foo with the given parameters. If * the service is already performing a task this action will be queued. * * @param context the context * @see IntentService */ // TODO: Customize helper method public static void startActionFoo(Context context) { try { Intent intent = new Intent(context, InitService.class); intent.setAction(ACTION_FOO); /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(intent); } else {*/ context.startService(intent); // } } catch (Exception e) { e.printStackTrace(); } } @Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (ACTION_FOO.equals(action)) { LoadInit(); } } } /** * 初始化操作資料 */ private void LoadInit() { CrashHandler crashHandler = CrashHandler.getInstance(); crashHandler.init(MyApplication.getAppContext()); JPushInterface.init(MyApplication.getAppContext()); if (JPushInterface.isPushStopped(MyApplication.getAppContext())) { JPushInterface.resumePush(MyApplication.getAppContext()); } MobclickAgent.setCatchUncaughtExceptions(true); MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(MyApplication.getAppContext(), Config.KEY,"Umeng", MobclickAgent.EScenarioType.E_UM_ANALYTICS_OEM,true)); MobclickAgent.enableEncrypt(true); MobclickAgent.setCheckDevice(true); } }
<service
android:name=".receiver.InitService"
android:exported="false" />
在application中這樣使用就好了
InitService.startActionFoo(context);