package com.jiuqi.njt.management.task; import android.content.Context; import android.os.AsyncTask; import android.telephony.TelephonyManager; import com.jiuqi.mobile.nigo.comeclose.bean.base.LbsPlanBean; import com.jiuqi.mobile.nigo.comeclose.exception.NiGoException; import com.jiuqi.mobile.nigo.comeclose.manager.base.ILbsPlanManager; import com.jiuqi.mobile.nigo.comeclose.ws.client.ClientContext; import com.jiuqi.njt.data.MyApp; import com.jiuqi.njt.data.OptsharepreInterface; import com.jiuqi.njt.update.Config; import com.jiuqi.njt.util.Constants; /** * 上传连续上报启动记录 * @author * */ public class UploadLocationUpStartTask extends AsyncTask<Void, Void, String>{ private Context context; public UploadLocationUpStartTask(Context context) { super(); this.context = context; } @Override protected String doInBackground(Void... params){ String msg = ""; try{ MyApp application = (MyApp) context.getApplicationContext(); ClientContext context = application.getClientContext(); OptsharepreInterface sharePre = new OptsharepreInterface(this.context); if(null==context){ context = ClientContext.getClientContext( Constants.SERVER_URL, sharePre.getPres("account"), sharePre.getPres("password")); application.setClientContext(context); } ILbsPlanManager manager = context.getManager(ILbsPlanManager.class); LbsPlanBean bean = new LbsPlanBean(); bean.setAccount(sharePre.getPres("account")); TelephonyManager tm = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE); String imsi = tm.getSubscriberId(); if(null==imsi||"".equals(imsi)){ imsi = "获取IMSI号失败"; } bean.setImsi(imsi); bean.setIp(Config.getLocalIpAddress(this.context)); bean.setTelephone(sharePre.getPres("mobileNumber")); bean.setCreateDate(); bean.setTime(String.valueOf(System.currentTimeMillis())); bean.setPhoneModel(android.os.Build.BRAND+android.os.Build.MODEL); manager.create(bean); } catch(NiGoException e){ e.printStackTrace(); } return msg; } @Override protected void onPostExecute(String result){ } }