每当我的应用程序启动时,我都必须从测试类调用打印方法。我从 MyApplication 类的 onCreate() 调用了这个打印方法,它扩展了 android.app.application 类。在 print() 方法中,我显示一条 toast 消息。但是,该 toast 消息没有显示。请帮忙!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(); }}
1 回答

慕容708150
TA贡献1831条经验 获得超4个赞
您还应该在以下位置声明您的自定义应用程序类manifest
:
<application android:name=".<your packages to the class>.MyApplication" ...>
添加回答
举报
0/150
提交
取消