Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Global Objects possible?

Global Objects possible?

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

Global Objects possible?

Postby paradroid666 » Tue Jun 01, 2010 8:16 am

Hi,

I have an application which consists of two activities. I want now to have some data objects which are global to my application, so that I can access them from both activities. Usually I create my objects in the onCreate method but then they are local. Can I have something like these global data objects?

Can I somewhere enter some global code that will be executed where I decide which activity is called?

Thanks.
P.
paradroid666
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri May 21, 2010 2:36 pm

Top

Re: Global Objects possible?

Postby anarche » Tue Jun 01, 2010 12:17 pm

You can serialise them and write them to file, to share between the apps.

Perform the serialisation in onStop() and deserialisation in onStart().

I can't think of any other way of sharing objects between Activities. If you need this for the design of your app, can I suggest you redesign the app? Maybe replace the second Activity with a Dialog?
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Global Objects possible?

Postby pskink » Tue Jun 01, 2010 12:37 pm

see:

http://developer.android.com/intl/fr/gu ... ement.html

and create your Application class

then you can call getApplication() to get its singleton instance
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 3 guests