之前已经问了一次,但这对我来说根本不起作用.所以我想我会再问一次.
我有一个JSONarray,我想使用intent传递给我的第二个活动.
这是我的代码的一部分,它连接到mysql数据库并将有关用户的数据放在JSONarray中.这一切都有效.
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
String ct_user;
String ct_pass;
Intent personal = new Intent(Home.this, Loggedin.class);
try{
jArray = new JSONArray(result);
JSONObject json_data=null;
json_data = jArray.getJSONObject(0);
ct_user = json_data.getString("user");
ct_pass = json_data.getString("pass");
if (passwordstring.equals(ct_pass)){
Bundle b = new Bundle();
b.putString("userdata",json_data.toString());
personal.putExtras(b);
startActivity(personal);
}
}
Run Code Online (Sandbox Code Playgroud)
我想通过对第二个活动(Loggedin)的意图发送我的完整JSONarray.这样我就可以显示例如ct_email = …