Hello I am trying to pass Json Data from Adapter to another Activity
playb = (ImageButton) row.findViewById(R.id.playbtn);
playb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Song newitem = getItem(position);
//long itemId = getItemId(position);
app = (myapplication) getContext().getApplicationContext();
app.setSong(item);
Intent intent1 = new Intent(getContext(), SongDetailedActivity.class);
intent1.putExtra("SongID", item.toString());
getContext().startActivity(intent1);
}
});
and my activity
Intent i = getActivity().getIntent();
hello = i.getIntExtra("SongID", 5);
Song event = app.getSongID(hello);
event.setSongID(hello);
In your activity,
Bundle bundle = getIntent().getExtras();
if(bundle != null && bundle.containsKey("SongID")){
String json = bundle.getString("SongID");
JSONObject jsonObject = new JSONObject(json);
//parse json from here...don't forget to handle JSONException
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments