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
[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 - Singleton Pattern+Activity?

Singleton Pattern+Activity?

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

Singleton Pattern+Activity?

Postby bavarol » Fri Jul 25, 2008 8:00 am

Hi all,
can I develop an activity as singleton class?

In google, they say, it's allowed but I get an "IllegalAccessException" exception

"An Error has occurred in process com.google.android.tour_guide. Unable
to instantiate activity ComponentInfo{name_of_package/name_of_package.name_of_activity}:
java.lang.IllegalAccessException: access to constructor not allowed"

If it's possible, what do I need?

public class Activity1 extends Activity {

private static Activity1 myInstance
private Activity1() {
//
}


public static synchronized Activity1 getInstance() {

if (myInstance == null) {
myInstance = new Activity1();
}
return myInstance;
}
}

It should be instantiated in other class like this:
Activity1 act = Activity1.getInstance();

What am I doing wrong?

Thx in advance
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests