Constant communication between 2 activities

Put your problem here if it does not fit any of the other categories.

Constant communication between 2 activities

Postby fawx » Fri Sep 11, 2009 8:27 am

hi

I am trying to start an activity which calls another sub-activity. That is fine. But the problem is, what if i want to constantly send data from the activity to the sub-activity every, say , 2 seconds and the sub-activity receives that data and appends it below the previous data, when ever it receives it.

How do i do this? I cant always call the startActivity(intent) method cause it would create a new UI every time.

Is there a way to make the main activity run in the background , constantly pumping in data and the sub-activity always visible, showing the data?

Should i be using a service? But how do i invoke an activity from a service? and how to transfer data constantly to the sub-activity?

Thanks
fawx
Junior Developer
Junior Developer
 
Posts: 11
Joined: Tue Aug 18, 2009 4:34 am

Top

Postby wiederke » Fri Sep 11, 2009 12:15 pm

Hi,

you should use the Application object. It is instanciated at application startup and known to each activity of the application. Store your data you need to access from more than one activity there.


cu

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Postby saamyandroid » Fri Sep 11, 2009 9:25 pm

Hi can u give one example?
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Postby wiederke » Mon Sep 14, 2009 12:40 pm

Hi,

here is an example.


bye

Torsten
Attachments
ActivityCommunication.zip
(35.01 KiB) Downloaded 201 times
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests