我有一個活動被2個意圖調用,一個簡單的菜單選擇之後,另一個意圖刪除一個數據庫中的項目。但是,我想在被叫活動中顯示一個小吐司,但只有當它通過刪除的意圖打開時。我想以下解決方案試圖在活動被意圖打開後嘗試做吐司
public void intentCheck(){
Log.d("ShowActivity","intentCheck() called");
Bundle extras = getIntent().getExtras();
if (extras != null){
String check = extras.getString("AdvancedViewActivityCall");
if(check == "calling"){
Log.d("ShowActivity","delete-intent succeeded");
Toast success = new Toast(ShowActivity.this);
success.makeText(ShowActivity.this, "Deletion succeded", Toast.LENGTH_LONG);
}
}
但它不工作......不知何故,沒有吐司得到顯示。
編輯://我申請了success.show();現在,但現在我得到一個RunetimeException O.o(http://pastebin.com/Th3NY5d0)
編輯:解:Toast.makeText(context, text, duration).show(); //seems to be the "static way", which eclipse proposed
沒了,給我第二.. 編輯://不起作用.. – Aeefire
我甚至可以返回「刪除-ntent成功」像這樣「呼叫」 =檢查,只是不知何故沒有按」 t開始敬酒.. eclipse引發了一些注意,靜態的.makeText應該以靜態方式訪問 – Aeefire
您的編輯,是它!謝謝!但是它似乎與「靜態引用」的日食暗示有關 – Aeefire