I have to call a print method from the test class whenever my application starts. I have called this print method from onCreate() of MyApplication class which extends android.app.application class. In the print() method, I am displaying a toast message. However , that toast message is not getting displayed.Kindly help!
public class MyApplication extends Application
{
@Override
public void onCreate() {
super.onCreate();
Test.print(this);
Toast.makeText(this,"On Create called",Toast.LENGTH_LONG).show();
}
}
public class Test {
static void print(Context context)
{
Toast.makeText(context,"Print called",Toast.LENGTH_LONG).show();
}
}
You should also declare your custom Application class in manifest
:
<application
android:name=".<your packages to the class>.MyApplication"
...>