MyActions:
package com.name.data;
public class MyActions {
private static final String TAG = "MyActions";
private static MyActions instance = null;
private boolean isTurntable, isSupply, isDoser, isCapper, isDebugging,
isManu, isAuto, isSetup, isHelp,
isStartAllUnit, isStartSelectedUnit, isCounterCounting;
private boolean forwardContinuous, backwardContinuous, forwardInterval, backwardInterval;
private boolean loginSuperUser, loginAdmin;
private boolean isJustStarted, isCounterService;
private int language,
doserTurnBackMax, doserManuSpeed, doserManuSpeedMax, doserManuTurnBack, doserManuTurnBackMax,
timeOfRoutineService, partSteps, maxPart;
private int count = 0, part = 0;
private long durationLongTouch;
private String currentProfile, pwSuperUser, pwAdmin, prefLocale;
private String [] listOfProfiles, listOfPumps, listOfDensitys, listLanguages;
private SelectedMainMenuItem selectionMainMenuItem;
private SelectedSubMenuItem selectionSubMenuItem;
private SelectedRotation selectionRotation;
private AmountUnit amountUnit;
private HeightUnit heightUnit;
private Density density;
private Pump pump;
private Filling filling;
private Profile profile;
private Profile profileEdit;
private MySqlAccess mySqlAccess;
private Context context;
/**
* Standartkonstruktor der Singleton-Klasse. Diesen NIEMALS direkt aufrufen, sonder immer nur MyActions.getInstance().
* Beim Starten der App zu aller erst MyActions.prepareInstance(this); aufrufen.
*/
public MyActions(){
Log.d(TAG, "MyActions()");
if ( instance == null ){
Log.e(TAG, "No no, das hätte nicht passieren dürfen!");
}
}
/**
* Hierin wird die einzige Instanz dieser Klasse erzeugt
* und anschliessend die initialisiert mit Werten (init().
* @param context
*/
private MyActions(Context context){
Log.d(TAG, "MyActions(Contextcontext)");
init(context);
}
/**
* <strong>public static MyActions getInstance()</strong><br />
* Gibt die einzige Instanz dieser Klasse zurück.
* @return (MyAction) - Instanz
*/
public static MyActions getInstance(){
if ( instance == null ){
instance = new MyActions();
}
return instance;
}
/**
* Statische Methode, erzeugt die einzige Instanz dieser Klasse.
*/
public static void prepareInstance(Context context) {
Log.d(TAG, "1. prepareInstance(Context context)");
if (instance == null){
instance = new MyActions(context);
}
}
private void init(Context context){
Log.d(TAG, "init(Context context)");
this.context = context;
context.getApplicationContext().registerReceiver(mReceiver, new IntentFilter(BottleAnimation.ACTION_BROADCAST));
context.getApplicationContext().registerReceiver(mReceiver, new IntentFilter(Counter.ACTION_BROADCAST));
// ABGFRAGE DES LETZTEN GENUTZTEN PROFILES
SharedPreferences settings = context.getSharedPreferences("pref", 0);
setCurrentProfile( settings.getString("currentProfile", "") );
amountUnit = new AmountUnit();
heightUnit = new HeightUnit();
density = new Density();
pump = new Pump();
filling = new Filling();
profile = new Profile();
profileEdit = new Profile();
setJustStarted(true);
setDebugging(false);
mySqlAccess = new MySqlAccess(context, this);
}
// ES FOLGEN ALLE GETTER UND SETTER
}```
Alle Methoden, die bei dieser Aktion unberührt bleiben, also nicht aufgerufen werden, habe ich raus genommen. Darin enthalten sind zB.Services (onReceive). Ebenso habe ich die Getter und Setter raus genommen.
ich sehe gerade:
public static MyActions getInstance()
und
public static void prepareInstance(Context context)
Hat das mit meinem Problem zu tun?
Was kann ich tun?