我正在向服务器发送请求并获得响应,并向下一个活动发送响应,作为响应,我有很多字段,看起来像这样
http://gujjumatch.com/webservice/searchresult?version=apps&user_login_id=2650
,但是当我发送到下一个活动时,只有一个jsonobject发送而不是整个对象,任何人都可以帮我这个吗?
public class SearchResults extends ListActivity{
private ProgressDialog pDialog;
private String Id;
private String results;
private ArrayList<HashMap<String,String>> aList;
private static String MATCH_URL = null;
private static final String TAG_MATCH="searchresult";
private static final String TAG_MATCH_ID="match_detail_id";
private static final String TAG_NAME="name";
private static final String TAG_PROFILE="profile_id";
private static final String TAG_IMAGE="image";
private static final String TAG_CAST="cast";
private static final String TAG_AGE="age";
private static final String TAG_LOCATION="location";
JSONArray searchresult=null;
private CustomAdapterSearch adapter;
private TextView nomathc;
private String Nam;
private String Pro;
private String Photo;
private String Jati;
private String Umar;
private String Jagya;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.list_view_searchresult);
Id=this.getIntent().getStringExtra("id");
System.out.println("searching id"+Id);
results=this.getIntent().getStringExtra("prmatch_id");
System.out.println("Results"+results);
Nam=this.getIntent().getStringExtra("prname");
System.out.println("Naam"+Nam);
Pro=this.getIntent().getStringExtra("prprofile");
System.out.println("Profilesss"+Pro);
Photo=this.getIntent().getStringExtra("primage");
System.out.println("Naam"+Photo);
Jati=this.getIntent().getStringExtra("prcast");
System.out.println("Naam"+Jati);
Umar=this.getIntent().getStringExtra("prage");
System.out.println("Naam"+Umar);
Jagya=this.getIntent().getStringExtra("prlocation");
System.out.println("Naam"+Jagya);
aList = new ArrayList<HashMap<String,String>>();
HashMap<String,String> idMap = new HashMap<String,String>();
idMap.put(TAG_MATCH_ID, Id);
idMap.put(TAG_NAME, Nam);
idMap.put(TAG_PROFILE, Pro);
idMap.put(TAG_IMAGE, Photo);
idMap.put(TAG_CAST, Jati);
idMap.put(TAG_AGE, Umar+" years");
idMap.put(TAG_LOCATION, Jagya);
aList.add(idMap);
//....
adapter = new CustomAdapterSearch(SearchResults.this, aList); // we create your adapter
setListAdapter(adapter); // we set the list adapter
nomathc=(TextView)findViewById(R.id.no_match);
}
答案 0 :(得分:0)
这个
有两个解决方案解决方案A:
解决方案B:
当json字符串的大小很大,即超过1MB时,它可能会导致ANR而不是parcelling。所以,遵循approch
答案 1 :(得分:-2)
你只需要一个包含所有对象的字符串..
JSONObject json = YOU JSON Object.
String myObject = json.toString();
Intent i = new Intent(this, SecontActivity.class);
i.putExtra("KEY",myObject);
在secont活动中。
Bundle extras = getIntent().getExtras();
if(extras !=null) {
String value = extras.getString("KEY");
} else {
String value = "Error";
}
JSONObject json = (JSONObject) new JSONParser().parse(value);