当前位置: 代码迷 >> Android >> 很简单的有关问题 这个值如何传过来
  详细解决方案

很简单的有关问题 这个值如何传过来

热度:48   发布时间:2016-05-01 13:25:03.0
很简单的问题 这个值怎么传过来?
imei += (char) (choice + random.nextInt(26));
   

   
上面得到的imei的值 想传到第二次点击 传到下面的参数里
 flag = WebHelper.regDeviceLogin(context, "login", imei, mac,getRunNumber());
 如何传过来?

看代码:




Java code
  @Override    public void onClick(View v) {        if(v.getId()==R.id.btn1){            if(flag ==0){                        //记录IMEI phonenumber            if(!WebHelper.REGISTER_FLAG){                Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == false");                  String imei = "", mac;                boolean flag;                TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); //                imei = tm.getDeviceId();//                imei = listt.get("mathInt");//                imei = "cer4512g5s4r843rt";                Random random = new Random();                for (int i= 0;i<=15;i++){                    String charOrNum = random.nextInt(2)%2 == 0? "char" : "num";                    if("char".equalsIgnoreCase(charOrNum)) // 字符串                         {                             int choice = random.nextInt(2) % 2 == 0 ? 65 : 97; //取得大写字母还是小写字母                             imei += (char) (choice + random.nextInt(26));                     }                         else if("num".equalsIgnoreCase(charOrNum)) // 数字                         {                             imei += String.valueOf(random.nextInt(10));                         }                                     }                if(imei == null){                    imei = "" + WebHelper.generateRandomIMEIString(15);                }                mac = null;                if(mac == null){                    mac = "" + WebHelper.generateRandomMacString(17);                }//                mobile_number = tm.getLine1Number();//                model = tm.getLine1Number();//                brand = tm.getLine1Number();                flag = WebHelper.regDevice(context, "install", imei, mac);                if(flag){                    WebHelper.REGISTER_FLAG = true;                    Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == true");                }                                            }            flag =1;            }else {                flag = WebHelper.regDeviceLogin(context, "login", imei, mac,getRunNumber());                flag =0;                            }        }


------解决方案--------------------
Private static char imei;
  相关解决方案