0

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();
    }
}
MohanKumar
  • 960
  • 10
  • 26
Shubh.J
  • 145
  • 1
  • 2
  • 12

1 Answers1

1

You should also declare your custom Application class in manifest:

<application
    android:name=".<your packages to the class>.MyApplication"
...>
RelaxedSoul
  • 644
  • 4
  • 10