| | |
| | | package com.anyun.exam.lib; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.util.Log; |
| | | |
| | | /** |
| | | * MyApplication2 |
| | |
| | | * All Rights Saved! Chongqing AnYun Tech co. LTD |
| | | */ |
| | | class AYSdk { |
| | | |
| | | private static final String TAG = "AYSDK"; |
| | | |
| | | //安运驾考系统 sdk 单例模式 |
| | | private volatile static AYSdk ourInstance = null; |
| | | private Context mContext; |
| | | private MyServiceConn conn; |
| | | |
| | | static AYSdk getInstance() { |
| | | if (ourInstance == null){ |
| | |
| | | return ourInstance; |
| | | } |
| | | |
| | | /** |
| | | * 初始化SDK |
| | | * @param context |
| | | */ |
| | | public void init(Context context){ |
| | | this.mContext = context; |
| | | //bind service |
| | | Intent intent = new Intent(mContext,RemoteService.class); |
| | | conn = new MyServiceConn(); |
| | | mContext.bindService(intent,conn,Context.BIND_AUTO_CREATE); |
| | | } |
| | | |
| | | /** |
| | | * 解绑 |
| | | */ |
| | | public void uninit(){ |
| | | if (mContext != null){ |
| | | mContext.unbindService(conn); |
| | | }else{ |
| | | Log.e(TAG,"mContext == null,please init SDK firstly"); |
| | | throw new RuntimeException("mContext == null,please init SDK firstly"); |
| | | } |
| | | } |
| | | |
| | | private AYSdk() { |
| | | |
| | | } |
| | | } |