android 银联支付接入报nullexception异常

packagecom.example.ex_example;importjava.io.ByteArrayOutputStream;importjava.io.InputStream;importjava.net.URL;importjava.net.URLConnection;importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.app.ProgressDialog;importandroid.content.DialogInterface;importandroid.os.Handler;importandroid.os.Message;importandroid.util.Log;importcom.unionpay.UPPayAssistEx;importcom.unionpay.uppay.PayActivity;publicclassUnionPayimplementsRunnable{//publicstaticfinalintPLUGIN_VALID=0;//publicstaticfinalintPLUGIN_NOT_INSTALLED=-1;//publicstaticfinalintPLUGIN_NEED_UPGRADE=2;/******************************************************************mMode参数解释:"00"-启动银联正式环境"01"-连接银联测试环境测试用卡号:6226440123456785*密码:111101*****************************************************************/privatefinalstaticStringmMode="01";privatestaticfinalStringTN_URL_01="http://202.101.25.178:8080/sim/gettn";privatestaticProgressDialogmLoadingDialog=null;privatestaticActivityactivity;privatestaticUnionPayunionPay=newUnionPay();publicstaticvoidunionpay(Activityactivity){UnionPay.activity=activity;mLoadingDialog=ProgressDialog.show(activity,//context"",//title"正在努力的获取tn中,请稍候...",//messagetrue);//进度是否是不确定的,这只和创建进度条有关/**************************************************步骤1:从网络开始,获取交易流水号即TN************************************************/newThread(unionPay).start();////支付金额订单金额//StringorderAmount="1533";////千引商户号//StringmerchantNO="805920100000069";////商户订单号//StringorderNO="467934311";////通知Url//StringbackUrl="http://www.baidu.com";////签名密钥//Stringkey="86Aab696Fed90bc691a7AfE0b6a269Ac";////签名字段//Stringsigncont=//merchantNO+"&"+orderNO+"&"+orderAmount+"&"+backUrl+"&"+key;////Log.e("",""+signcont);////Stringsign=MD5.digest(signcont);////Stringsign=MD5Utils.generate(signcont);//Log.e("","sign="+sign.length());//Stringurl="http://mpay.sinoqy.com:6283/qyapi/trans/getTn"//+"?orderAmount="+orderAmount//+"&merchantNO="+merchantNO//+"&orderNO="+orderNO//+"&backUrl="+backUrl//+"&Sign="+sign;////Log.e("",""+url);//////获取TN//HTTPUtils.get(this,url,newVolleyListener(){////@Override//publicvoidonErrorResponse(VolleyErrorarg0){//Log.e("","VolleyError="+arg0);//}////@Override//publicvoidonResponse(Stringarg0){//Log.e("","onResponse="+arg0);//}//});//}//银联privatestaticHandlermHandler=newHandler(){publicvoidhandleMessage(android.os.Messagemsg){if(mLoadingDialog.isShowing()){mLoadingDialog.dismiss();}Stringtn="";if(msg.obj==null||((String)msg.obj).length()==0){AlertDialog.Builderbuilder=newAlertDialog.Builder(activity);builder.setTitle("错误提示");builder.setMessage("网络连接失败,请重试!");builder.setNegativeButton("确定",newDialogInterface.OnClickListener(){@OverridepublicvoidonClick(DialogInterfacedialog,intwhich){dialog.dismiss();}});builder.create().show();}else{tn=(String)msg.obj;/**************************************************步骤2:通过银联工具类启动支付插件************************************************/doStartUnionPayPlugin(activity,tn,mMode);}}};//银联publicstaticvoiddoStartUnionPayPlugin(Activityactivity,Stringtn,Stringmode){Log.e("","handleMessage");//TODO//orderInfo――订单信息为交易流水号,即TN。//mode――银联后台环境标识,“00”将在银联正式环境发起交易,“01”将在//银联测试环境发起交易UPPayAssistEx.startPayByJAR(activity,PayActivity.class,null,null,tn,mode);}@Overridepublicvoidrun(){Log.e("","run");Stringtn=null;InputStreamis;try{Stringurl=TN_URL_01;URLmyURL=newURL(url);URLConnectionucon=myURL.openConnection();ucon.setConnectTimeout(120000);is=ucon.getInputStream();inti=-1;ByteArrayOutputStreambaos=newByteArrayOutputStream();while((i=is.read())!=-1){baos.write(i);}tn=baos.toString();is.close();baos.close();}catch(Exceptione){e.printStackTrace();}Messagemsg=mHandler.obtainMessage();msg.obj=tn;mHandler.sendMessage(msg);}}


这是我自己整合的银联支付,在

packagecom.example.ex_example;importandroid.os.Bundle;importandroid.support.v7.app.AppCompatActivity;importandroid.view.View;publicclassMainActivityextendsAppCompatActivity{@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}publicvoidclick(Viewv){//调用UnionPay.unionpay(this);}}


出现如下异常:


找了N久才找到问题:(该死的这文件没考)


希望大家注意。