adamine
adamine

Reputation: 143

starting activity needs application call, android

today i wanted to add a functionnality in my app, after downloading the code and adding it to my project files, it seems that before calling the main activity of this functionnality, a class(AppController) extending Application should be called first! Because its onCreate methode initialise some important things:

@Override
public void onCreate() {
super.onCreate();
mInstance = this;
pref = new PrefManager(this);
}

so the think is: before doing that:

Intent intent = new Intent(getActivity(),Wallapers.class);
startActivity(intent);

i should call the application AppController. In the code project i have downloaded it's called in the android manifest, but since i already have an application called there i can't call more than one. Thank you !

Upvotes: 1

Views: 44

Answers (1)

Awanish Raj
Awanish Raj

Reputation: 2009

The easiest way would be to merge the code for both the Application classes into one, and assign that name in AndroidManifest.xml.

Let's say you have two Application java files MyApplication.java and AppController.java.

You have said that AppController.java has

@Override
public void onCreate() {
    super.onCreate();
    mInstance = this;
    pref = new PrefManager(this);
}

Then merge into onCreate() of MyApplication.java as follows

@Override
public void onCreate() {
    super.onCreate();

    //Code from MyApplication.java

    mInstance = this;
    pref = new PrefManager(this);
}

I am guessing you are new to this. Hope this helps! :)

Upvotes: 1

Related Questions