Description
when the app's WXInstance destroy, but Weex page call toast(),sometimes app crash, because null point exception context is null !!!, inside toast().
code class WXModalUIModule:
@JSMethod(uiThread = true)
public void toast(String param) {
String message = "";
int duration = Toast.LENGTH_SHORT;
if (!TextUtils.isEmpty(param)) {
try
catch (Exception e)
{ WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); }}
if (TextUtils.isEmpty(message))
if (duration > 3)
{ duration = Toast.LENGTH_LONG; }else
{ duration = Toast.LENGTH_SHORT; }if (toast == null) {
//crash here!!!! sometime, mWXSDKInstance.getContext() is null !!!!
t*oast = Toast.makeText(mWXSDKInstance.getContext(), message, duration);*
} else
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
ps:when weex page closed, and wxSDKInstance destroy,but weex page still working on background like asynchronous request(network),on this time.when the request is back, and call toast(),now context is null,bug show!