Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Fix facebook#5599: toast doesn't disappear after app exited.
Browse files Browse the repository at this point in the history
Summary:Run `Toast.makeText` other than UI Thread will cause bug facebook#5599 : toast doesn't disappear after app exited.

use `UiThreadUtil.runOnUiThread` to fix this.
Closes facebook#6443

Differential Revision: D3047261

fb-gh-sync-id: 0096879f2a4b4d76bda996a32089f068ae68e3f3
shipit-source-id: 0096879f2a4b4d76bda996a32089f068ae68e3f3
  • Loading branch information
tdzl2003 authored and Facebook Github Bot 8 committed Mar 22, 2016
1 parent e691b7c commit 90aa7b9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.bridge.UiThreadUtil;

import java.util.Map;

Expand Down Expand Up @@ -46,7 +47,12 @@ public Map<String, Object> getConstants() {
}

@ReactMethod
public void show(String message, int duration) {
Toast.makeText(getReactApplicationContext(), message, duration).show();
public void show(final String message, final int duration) {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run(){
Toast.makeText(getReactApplicationContext(), message, duration).show();
}
});
}
}

0 comments on commit 90aa7b9

Please sign in to comment.