Category : singleton

I am trying to call function sleep from my Utils as the below code: @Override public void onError(String err) { log("A pinger died"); if (errorHandlingMode.equals(SpeedtestConfig.ONERROR_FAIL)) { PingStream.this.onError(err); return; } if (errorHandlingMode.equals(SpeedtestConfig.ONERROR_ATTEMPT_RESTART) || errorHandlingMode.equals(SpeedtestConfig.ONERROR_MUST_RESTART)) { Utils.sleep(100); init(); } } and this is the full function I have: private void init() { if (stopASAP) return; if (c ..

Read more

I have a singleton class that has 2 Hashmaps, both private with their own individual(tested and working) getters and setters private static Property property = new Property(); public static Property getInstance(){ return property; } private HashMap<String, Object> roomReturnedObj = new HashMap<>(); private HashMap<String, Object> roomTasks = new HashMap<>(); public void setRoomObj(HashMap<String, Object> roomHashMap) { roomReturnedObj.putAll(roomHashMap); ..

Read more

How to use Singleton class for Cronet i have already worked on volley & retrofit library for getting several connections to prevent out of memory issue i used singleton. i am novice in cronet, i dont know how to apply Singleton class. please provide answer. My code: Post Method Example: val myBuilder = CronetEngine.Builder(context) // ..

Read more

EDIT: I NEED TO PASS A CONTEXT AS A PARAMETER TO THE CLASS (DataStore and repository is the same class, don’t get confused) I have two activities, A and B and one repository. Activity A opens activity B and activity B saves data in the repository(DataStore a part of android jetpack). I am using LiveData ..

Read more

I opened a new question because it’s really specific and I’m fresh new to singleton. So instanciation doesn’t solve my problem (without finding the instance on the other activity, which I don’t know if it’s possible) but compiles, and implementation of singleton (it’s in the code below) result in error: error: Illegal static declaration in ..

Read more