java - Sending JSON object from activity to Fragment -


Hey people

I'm still looking for an answer for hours. Could you please help. It's really important.

What I am trying to do, is to get Jason's object in an acetate in the login activity and then send this piece to a piece where I will parse it.

The login activity is an acetcus where I try to send Jasonson (which I get from () as a rutin):

  @ Override protected voice downline background (zero ... parameter) {string JSON = faucet; {JSON = New String (check post ()); Bundle bundle = new bundle (); Bundle.putstring ("jestring", json); Timetable fragobj = new timetable (); fragobj.setArguments (bundle); } Hold (IOException e) {e.printStackTrace (); }}   

And here's my piece (Timetable class) where I try to get JSON in onCreatView

  string jsonString = getArguments ( ). GetString "jString"); JSONObject jsonObject = new JSONObject (jsonString);   

My problem with everyone is that when I try to get jsonString with getArguments, I always get a NullPointerException.

Any help would be appreciated.
cheers

PS I hope my post is not chaotic XD

Use the one instead of passing the variable from the non-taskable task to the foreground, and then pass it back ...

Do the following in your AsyncTask:

  The public interface WebServiceResult {Zero OnWebService (int type, string result); }   

In the same way I have set it up so that I can use the same web service for many different calls.

In your AsyncTask, create a constructor and tell it the interface:

  WebServiceResult listener; Public Website (Reference C, WebServient Listener, JSONObject jObject, int typeofCall) {this.c = c; this.typeofCall = typesofCall; This.listener = Listener; this.jObject = jObject; }   

Code from your app.

Then after the completion of the call, your JSO to doInBackground your onPostExecute

  if (result! = Null) {if (listener! = Null) listener.OnWebService ( TypeofCall, results); } Else {// Other Statement}   

This variable sends back your activity which you can send to pieces using getArguments.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -