每當我的應用程序啟動時,我都必須從測試類調用打印方法。我從 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
提交
取消