原因

因为在Application的onCreate有很多第三方平台的初始化工作,所以造成启动慢

解决方法

创建一个子线程来处理,最好的是使用IntentService来启动子线程进行处理,因为IntentService在处理完成后会自动停止,不用手动销毁线程。

private static final String ACTION_INIT_WHEN_APP_CREATE = "com.demo.app.service.action.INIT";@Overrideprotected void onHandleIntent(Intent intent) {    if (intent != null) {        final String action = intent.getAction();        if (ACTION_INIT_WHEN_APP_CREATE.equals(action)) {            performInit();        }    }}

在创建一个启动service的方法供调用

public static void start(Context context) {    Intent intent = new Intent(context, InitializeService.class);    intent.setAction(ACTION_INIT_WHEN_APP_CREATE);    context.startService(intent);}

更多相关文章

  1. Android(安卓)adb启动任意app的几种方式
  2. 消息处理机制 —Handler/Thread/Looper & MessageQueue
  3. android HandlerThread源码解析
  4. Android中的几种多线程实现
  5. Android(安卓)Toast 用法总结
  6. Android界面刷新
  7. 走进Java Android(安卓)的线程世界(三)Hander消息机制
  8. Android(安卓)进阶——Framework 核心四大组件之跨进程共享组件C
  9. Android(安卓)双开沙箱 VirtualApp 源码分析(四)启动插件 Service

随机推荐

  1. 浅入浅出 Android 安全 (四) Android 框架
  2. Android Overdraw
  3. Android 敏感词过滤实现
  4. 2012移动开发者大会上海站Android专场
  5. 图解 Android 系列(一)揭秘 Android 系统启
  6. Android APK 签名、打包笔记
  7. Android:自定义PopupMenu的样式(显示图标/
  8. android的优点与不足
  9. Archos G9 平板將在 2012 年「前三月」得
  10. android Media原理学习