標籤:style class blog code java ext
真機測試時個別機型toast資訊不顯示,找到兩個解決方案,不知還有什麼其它有效方法,期待大神們的分享!!!
1、手動方案:設定——>應用軟體管理——>對應APP——>勾選顯示通知框
2、替代方案:避免toast被攔截,可以考慮用alert dialog來顯示需要的資訊
public static void forceUpdate(){Log.i(TAG, "forceUpdate");//UmengUpdateAgent.forceUpdate(mActivity);UmengUpdateAgent.update(mActivity);UmengUpdateAgent.setUpdateAutoPopup(false);UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() { @Override public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) { switch (updateStatus) { case 0: // has update UmengUpdateAgent.showUpdateDialog(mActivity, updateInfo); Log.i(TAG, "forceUpdate1"); break; case 1: // has no update// Toast.makeText(mActivity, "當前已是最新版本", Toast.LENGTH_SHORT)// .show(); BaseHelper.showAlert(mActivity,"", "當前已是最新版本","確定"); Log.i(TAG, "forceUpdate2"); break; case 2: // none wifi// Toast.makeText(mActivity, "沒有wifi串連, 只在wifi下更新", Toast.LENGTH_SHORT)// .show(); break; case 3: // time out// Toast.makeText(mActivity, "逾時", Toast.LENGTH_SHORT)// .show(); BaseHelper.showAlert(mActivity,"", "版本檢查逾時,請稍候重試","確定"); Log.i(TAG, "forceUpdate3"); break; } }});}
public static void showAlert(Context context,String title, String message,String confirmStr) {new AlertDialog.Builder(context).setIcon(R.drawable.icon).// 表徵圖setTitle(title).// 標題setMessage(message).// 提示內容setPositiveButton(confirmStr, new DialogInterface.OnClickListener() {// 確定@Overridepublic void onClick(DialogInterface arg0, int arg1) {// yes to do}}).show();}