Created
April 30, 2011 17:42
-
-
Save methodin/949830 to your computer and use it in GitHub Desktop.
Toast handler for Android (avoids contextual errors)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need a handler for toast | |
public void makeToast(String str) { | |
Message status = toaster.obtainMessage(); | |
Bundle datax = new Bundle(); | |
datax.putString("msg", str); | |
status.setData(datax); | |
toaster.sendMessage(status); | |
} | |
public Handler toaster = new Handler(){ | |
@Override | |
public void handleMessage(Message msg) { | |
Toast.makeText(getBaseContext(), msg.getData().getString("msg"), Toast.LENGTH_SHORT).show(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment