WMSApplication.java 2 KB
package com.huaheng.wms;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.RemoteException;

import com.huaheng.wms.util.CrashHandler;
import com.huaheng.wms.util.SoundUtils;
import com.huaheng.wms.util.SpeechUtil;
import com.huaheng.wms.wmsgreendao.DaoMaster;
import com.huaheng.wms.wmsgreendao.DaoSession;

import com.iflytek.speech.ErrorCode;
import com.iflytek.speech.ISpeechModule;
import com.iflytek.speech.InitListener;
import com.iflytek.speech.SpeechConstant;
import com.iflytek.speech.SpeechSynthesizer;
import com.iflytek.speech.SynthesizerListener;

import org.xutils.x;


public class WMSApplication extends Application {

    private static String cookie;
    //  greenDao
    private DaoMaster.DevOpenHelper mHelper;
    private SQLiteDatabase db;
    private DaoMaster mDaoMaster;
    private DaoSession mDaoSession;
    private static Context mContext;

    @Override
    public void onCreate() {
        super.onCreate();
        SoundUtils.getInstance(this);
        setupDataBase();
        CrashHandler.getInstance().init(this);
        x.Ext.init(this);
        x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
        mContext = this;
        SpeechUtil.getInstance(mContext).initSpeech();
    }

    public static String getOkhttpCookie() {
        return cookie;
    }

    public static void setOkhttpCookie(String result) {
        cookie = result;
    }

    /**
     * 初始化数据库
     */
    private void setupDataBase() {
        mHelper = new DaoMaster.DevOpenHelper(this, "WMSApplication", null);
        db = mHelper.getWritableDatabase();
        mDaoMaster = new DaoMaster(db);
        mDaoSession = mDaoMaster.newSession();
        WMSLog.d("setupDataBase");
    }


    public DaoSession getDaoSession() {
        return mDaoSession;
    }
    public SQLiteDatabase getDb() {
        return db;
    }

    public static Context getContext(){
        return mContext;
    }


}