In my application i have to share various java-beans class among the activities.
In order to do that, i extended the Application class, in which i create an HashMap filled with all the java-beans. Each java-beans has its own Key.
Example code:
public class MyApplication extends Application {
    public static final String CLASSROOM_KEY = "Classroom";
    private HashMap<String, Object> myObjects;
    @Override
    public void onCreate() {
        myObjects = new HashMap<String, Object>();
        myObjects.put(CLASSROOM_KEY, new Classroom());
    }
    public HashMap<String, Object> getMyObjects() {
        return myObjects;
    }
}
This is usable in all the activities, and this is ok. BUT, i have two problems:
1) I need to get myObjets also in non-activity classes, like utils classes, but in these classes i can't do "getApplicationContext()" because they don't extend Activity.
For example, from my main activity i start a service (but it is in a normal class), and the service calls a query that in turn is in another normal class.
The query needs an object that is in myObjects!
I can't make myObjects public static i think.
2) In MyApplication i have to create all my java-beans in advance.
What if in the future i wanted to create a new classroom object in addition to the already present one? I should create a new key for it, but it is impossible!
Thanks for your help.
UDPATE
I change the question:
In this class:
public class ClassroomUtils {
    private static String result = null;
    private static String studentObjectID = null;
    public static void queryClassroom(String UUID, final Classroom classroom) {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Classroom");
        query.whereEqualTo("BeaconUUID", UUID);
        query.getFirstInBackground(new GetCallback<ParseObject>() {
            public void done(ParseObject object, ParseException e) {
                if (e == null) {                        
                    try {
                        result = object.getString("Label");
                    } catch(Exception e1){
                        System.out.println("Vuota");
                    }
                    if(result != null) {
                        Log.i("Classroom", "Retrieved " + result );
                        classroom.setClassroom(result);
                        sendNotification(result);
                        addStudentClassroomRelation(object);
                    }
                } else {
                    Log.e("Classroom", "Error: " + e.getMessage());
                }    
            }
        }); 
    }
i want to avoid to pass the classroom to this method (called from another normal class). How can i access to global objects from this class?
 
     
    