Questions tagged [application-singleton]

18 questions
55
votes
2 answers

Android Singleton with Global Context

Per the Android Documentation it states: There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way. If your singleton needs a global context (for example to…
Derek Gebhard
  • 917
  • 2
  • 10
  • 15
10
votes
3 answers

Android: Best way to save data stored in Application Singleton Class

What's the best way to save the data stored in the Application Class (singleton) of an Android Application? I have a quiet big app that shares a lot data between the activities. So most of it is stored on the Application Singleton. It all works…
neteinstein
  • 17,529
  • 11
  • 93
  • 123
7
votes
1 answer

Maximize application in system tray?

I wrote a little WPF app that when 'closed' minimizes to the system tray (customer requirement). Double clicking pops it back up, or right click gives a context menu to exit. But if the app is minimized, and the users navigate to Start->All…
Nicros
  • 5,031
  • 12
  • 57
  • 101
3
votes
2 answers

Playframework: Best Solution for loading & using constant Strings

I have a bunch of static Strings that I'd like to store in a .yml file. What's the best design practice to load them to a Java Class & use it. In other words, I'm looking for an Application-wide Singleton class holding resource strings, but confused…
roshan
  • 1,323
  • 18
  • 31
3
votes
2 answers

Singleton managedObjectContext

I want to use the singleton UIApplication to access the managedObjectContext of the AppDelegate. But when I write [[[UIApplication sharedApplication] delegate] managedObjectContext] or [[[UIApplication sharedApplication] delegate]…
2
votes
2 answers

Consequences of Singletons

So I just delved into the Singleton classes and yes, I find them quite helpful. I use my singletons mostly for data storage for multiple targets (views, tables etc.). That being said, I can already see myself going to implement a lot of singletons…
Gerald Eersteling
  • 1,244
  • 14
  • 28
2
votes
4 answers

.NET - limiting the number of instances of an execution unit

Let's say I have an application written in C# called EquipCtrl.exe which runs as a local process on a PC to control a piece of equipment. Obviously, I would wish to have only one instance of Equipctrl to run on each PC. If I had two equip to control…
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
2
votes
3 answers

Is singleton preferable for Android? Why?

I went some interviews, there are asking the below question. Please help me. Is singleton preferable for Android? Why? I googled but I didn't get the correct solution. Please give me correct answer.
Navadeep
  • 49
  • 1
  • 10
1
vote
1 answer

Singleton objects and AppPool Recycling

I am currently building rest services that authenticate user against a kerberos domain controller. Since poking the KDC everytime a user tries to do an action in the system is time-consuming, I have a cache where I store an authentication token with…
Jazzwave06
  • 1,883
  • 1
  • 11
  • 19
1
vote
2 answers

Android extending Application pattern doubts

I have extended my Application in my Android App in order to store the different typefaces I use within my application. Everything is working fine, however I am not understanding the singleton part of the code and what is the goal of the getInstance…
Bernardo
  • 531
  • 1
  • 13
  • 31
1
vote
1 answer

User info. Use singleton class or not?

My app will be used by one user. However, there will be a lot of user related info. So i have a class called User.h/.m and @property many fields. One one instance will be made of this class since only one user will be using the phone. My question…
1
vote
2 answers

Is overriding Application class and access it through static variable safe?

In my android application, I'm overriding Application class like below. public class MyApplication extends Application { private static MyApplication instance = null; @Override public void onCreate() { super.onCreate(); …
Onur
  • 5,617
  • 3
  • 26
  • 35
1
vote
1 answer

Parcelable or Singleton?

I am working on a project that involves me having to share an array list of objects with all of the activities that make up the application. Until recently I was passing the list between activities by implementing the parcelable interface. An…
Javacadabra
  • 5,578
  • 15
  • 84
  • 152
0
votes
2 answers

Instantiate singleton class objects in Android

Can anyone tell me where to instantiate a singleton class object like ArrayList? I am trying to instantiate in the onCreate() method but its not instantiated. Can any one tell me where to allocate it? public class SharedVariables extends Application…
Bad Boy
  • 628
  • 2
  • 5
  • 23
0
votes
1 answer

Android Singleton for "User data" saved to JSON file

Right now, my app is using a singleton class `UserData' to maintain user preferences and settings. I have it save all data to a JSON file every time a change is made. So, all of my setters call saveToFile(). This is working just fine, but I just…
Rick Falck
  • 1,778
  • 3
  • 15
  • 19
1
2