开发者

trying to make Toast after Activity gets opened by intent

I have an activity which gets called by 2 intents, one after a simple menu-selection and the other way by a intent after a deletion of an item in a database. However, I wanted to display in the called activity a little Toast, but only when it's opened through the intent of the deletion. I thought of following solution

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); 

            }
        }

but it doesn't work... somehow, no toast gets displayed.

edit:// i applied success.show(); now, but now i get a RunetimeException O.o ( http://pastebin.com/Th3NY5d0 )

edit: SOLUTION: Toast.makeText(context, text, duration).show(); //seem开发者_运维技巧s to be the "static way", which eclipse proposed


Have you tried if ("calling".equals(check)) instead of if(check == "calling") ?

EDIT: try Toast.makeText(context, text, duration).show();


you have to call show method for toast until otherwise toast will not display.

success.show();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜