I have a class which extends Application and i want to call it from code, it have
@Override
public void onCreate()
I need to call this from an Activity. I know how to call it when app starts for that i need to include in manifest:
android:name=""
Thanks.
You should avoid Calling Applications onCreate manually, as it will get started automatically if anything is configured correctly. However, If you want to call Methods from your overridden Application you can do it like this:
public class MyApplication extends Application{
public void someMethod(){}
}
then inside any Activity:
MyApplication app = (MyApplication)getApplication()
app.someMethod();
Try this :
public class YourApplication extends Application
{
public void sayHello {
System.out.println("Hello")
}
}
Then call it in any activity by:
YourApplication appState = ((YourApplication)this.getApplication());
appState.sayHello();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With