java - Android - Passing Intent from SherlockFragment to normal Activity class -
I am trying to pass two strings in a normal class, but when I try to get the data < / P> and general class: The I do not think the data structure There is a problem Onki when I print it on the screen, it works fine, it is intended that does not work. If you can drag an exception stack trace from the log then it would be useful. I think I'm just getting the code, but guess: My guess is that If the intention does not have any extra, Post your lockback and we will see how my theory is. last int a = i; Blog [i] .setOnClickListener (see new OnClickListener) {public void onClick (see v) {intent i = new (getActivity), ReadBlog.class) {i.putExtra ("title", jsons [a] GetString ("title"); i.putExtra ("text", jsons [a] .getstring ("text");} hold (JSONException e) {// TODO auto generated blocking block e.printStackTrace (); } Initialization (i); log. E ("button", "blog clicked");}});
increases the readbound activity of the public class {@ Override Protected Zero (Creates the Bundle InstantStatus) {This. Request WindowFirst (window.FEATURE_NO_TITLE); Super.onCreate (savedInstanceState); //setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); SetContentView (R.layout.readblog); String title = "title"; // intent.getStringExtra ("title"); String text = "text"; Text = getIntent (). GetExtras () GetString ("text"); TextView titlev = (TextView) Find ViewById (R.id.textView1); Titlev.setText (title); TextView textv = (TextView) findViewById (R.id.textView2); Textv.setText (text); }}
ReadBlog class appears with the correct text for a second before the crash - there is no error message, only a specific Android that is actually In the
07-24 22: 12: 37.130: E / pass 2.2 (22138): Blog - Connection Success 07-24 22: 12: 37.800: E / Button (22138) : Clicked on the blog 07-24 22: 12: 37.830: W / Dalvikum (22138): thread = 1: without exception (group = 0x40f21438)
part 1: reason
Try {i.putExtra (" title ", Jason [A] .getstring (" title ")); I.putext ("text", Jason [A] .getstring ("text"); } Grip (JasonAxpection E) {// Two-Auto Auto-Generated Catch Block E.Pintstaxtress (); }
jsons [a] .getString ("title") throws an exception or gives blank space in any way Any additional
intent can not be added to , intended to start other activity, it works fine, but there is no extra in it.
Part 2: Effects
text = getIntent (). GetExtras () GetString ("text");
getExtras () return is empty, therefore,
.getString ("text") After that a NullPointerExcpetion throws I believe this is an exception, which "unfortunately, your app has stopped."
Comments
Post a Comment