您好,欢迎访问一九零五行业门户网

activity-Postparameter报错误信息

activitymysqlandroidandroid intent
我建了一个app,在应用程序中,当点击按钮时就发送一个字符串给下一个activity,在第二个activity中我用这个值从数据库中检索数据。
下边是代码
intent myintent = getintent(); // 从前一个activity中获得值myintent.getstringextra(lbl_name);postparameters = new arraylist();postparameters.add(new basicnamevaluepair(product, lbl_name//传递name给database .gettext().tostring()));
问题是它不会继承lbl_name
我在网上找了很久,但是都没有找到解决方法。麻烦告诉我一下这么做对不对?
传递值的代码.
intent myintent = new intent(singleplaceactivity.this,recoprod.class); myintent.putextra(lbl_name, lbl_name); singleplaceactivity.this.startactivity(myintent);
访问数据库的代码.
public class recoprod extends activity { edittext pd; textview error; arraylist postparameters; /** 当activity第一次被创建的时候调用 */ @override public void oncreate(bundle savedinstancestate) { try { class> strictmodeclass = class.forname(android.os.strictmode, true, thread.currentthread() .getcontextclassloader()); class> threadpolicyclass = class.forname(android.os.strictmode$threadpolicy, true, thread .currentthread().getcontextclassloader()); class> threadpolicybuilderclass = class.forname(android.os.strictmode$threadpolicy$builder, true, thread.currentthread().getcontextclassloader()); method setthreadpolicymethod = strictmodeclass.getmethod(setthreadpolicy, threadpolicyclass); method detectallmethod = threadpolicybuilderclass.getmethod(detectall); method penaltymethod = threadpolicybuilderclass.getmethod(penaltylog); method buildmethod = threadpolicybuilderclass.getmethod(build); constructor> threadpolicybuilderconstructor = threadpolicybuilderclass.getconstructor(); object threadpolicybuilderobject = threadpolicybuilderconstructor.newinstance(); object obj = detectallmethod.invoke(threadpolicybuilderobject); obj = penaltymethod.invoke(obj); object threadpolicyobject = buildmethod.invoke(obj); setthreadpolicymethod.invoke(strictmodeclass, threadpolicyobject); } catch (exception ex) { string tag = null; log.w(tag, ex); } super.oncreate(savedinstancestate); setcontentview(r.layout.recomain); intent myintent = getintent(); // 从前一个activity中获得值 string lbl_name= myintent.getstringextra(lbl_name);//(); postparameters.add(new basicnamevaluepair(product, lbl_name )); // string valid = 1; downloadwebpagetask dw = new downloadwebpagetask(); dw.execute(); } private class downloadwebpagetask extends asynctask { @override protected string doinbackground(string... urls) { string response = null; for (string url : urls) { try { response = customhttpclient.executehttppost(http://192.168.1.7/abc/check2.php, postparameters); string res = response.tostring(); // res = res.trim(); res = res.replaceall(\\s+, ); // error.settext(res); try{ res = ; jsonarray jarray = new jsonarray(res); for(int i=0;i + json_data.getstring(prod_name); } } catch(jsonexception e){ log.e(log_tag, error parsing data +e.tostring()); } try{ error.settext(res); } catch(exception e){ log.e(log_tag,error in display! + e.tostring());; } } catch (exception e) { log.e(log_tag,error in http connection!! + e.tostring()); } } return response; } @override protected void onpostexecute(string result) { } }}
其它类似信息

推荐信息