0

Im new to android. I wanted to develop an application with the following screens

Login

Menu

News

After login, the Menu activity will be displayed. On clicking on News option from the menu activity I would like to display the News screen. I will have to send a message to the server and on receiving the reply, the data received in the Reply message will have to be displayed in the News Activity.

  1. Can I start an intent service from the Menu screen and handle SENDING and RECEIVING the messages in that. On receiving the message (its on a different thread - API thread), broadcast it to Activity using Broadcast Receiver? or How do I do this?

  2. I have a DATE field in the News screen and on changing the date, the data has to be refreshed.i.e Request has to be sent to the server with the modified date and the updated data received has to be displayed. How can this be achieved?

Please help.

John Snow
  • 5,214
  • 4
  • 37
  • 44
Nini
  • 43
  • 5

2 Answers2

0

Have a look at http://stackoverflow.com/a/25319126/478230 for instructions on using BroadcastReceivers to get callbacks from an IntentService

Thira
  • 1,555
  • 1
  • 13
  • 24
0

1.Check the links - Sending and Parsing JSON Objects , http://www.vogella.de/articles/AndroidJSON/article.html

2.OnResume()

How to get Spinner value?

Community
  • 1
  • 1
Jason Wood
  • 737
  • 1
  • 13
  • 22
  • Thank you for your reply and Sorry for the delay in responding. #1 Passing the data is not an issue. Is the design right? For this purpose, should we use only Intent Service & Activity or is there any other alternative. #2 Im calling startService() everytime as the sending request part is in IntentService. Is that correct? or Is there any other way I can trigger IntentService to send the request? – Nini Mar 28 '12 at 12:57
  • you can use jsonfunctions.java file online for parsing and check this link- http://p-xr.com/android-tutorial-how-to-parse-read-json-data-into-a-android-listview/ you can go through the source code.Accept my answer if you resolves your query. – Jason Wood Mar 28 '12 at 22:16
  • My question is not about passing DATA. I wanted to confirm the design/flow of the application. For sending a message and receiving the reply from server, can we use IntentService. If so, how do I call service each and every time? I think its advisable to call startService() only once. – Nini Mar 29 '12 at 12:21
  • I have never used this service,but if you want to send data and receive response for every call use : JSONObject json =JSONfunctions.getJSONfromURL("http://yourserver/dataforsearch") evertime ,if its about the value use bundle to send from one intent to another. – Jason Wood Mar 30 '12 at 09:18