Fix #5599: toast doesn't disappear after app exited.
Summary:Run `Toast.makeText` other than UI Thread will cause bug #5599 : toast doesn't disappear after app exited. use `UiThreadUtil.runOnUiThread` to fix this. Closes https://github.com/facebook/react-native/pull/6443 Differential Revision: D3047261 fb-gh-sync-id: 0096879f2a4b4d76bda996a32089f068ae68e3f3 shipit-source-id: 0096879f2a4b4d76bda996a32089f068ae68e3f3
This commit is contained in:
parent
e691b7c9f4
commit
90aa7b951d
|
@ -17,6 +17,7 @@ import com.facebook.react.bridge.ReactContext;
|
||||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||||
import com.facebook.react.bridge.ReactMethod;
|
import com.facebook.react.bridge.ReactMethod;
|
||||||
import com.facebook.react.common.MapBuilder;
|
import com.facebook.react.common.MapBuilder;
|
||||||
|
import com.facebook.react.bridge.UiThreadUtil;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -46,7 +47,12 @@ public class ToastModule extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void show(String message, int duration) {
|
public void show(final String message, final int duration) {
|
||||||
Toast.makeText(getReactApplicationContext(), message, duration).show();
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
Toast.makeText(getReactApplicationContext(), message, duration).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue