为什么我的扩展android.app.application的应用程序类无法正常工作?

问题描述 投票:-1回答:1

每当我的应用程序启动时,我都必须从测试类中调用打印方法。我从MyApplication类的onCreate()调用了此打印方法,该方法扩展了android.app.application类。在print()方法中,我正在显示一条祝酒消息。但是,该吐司消息未显示。请帮助!

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();
    }
}
java android oncreate android-application-class
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.