You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/31 03:15:00 UTC

[jira] [Commented] (WEEX-474) Toast ,crash!

    [ https://issues.apache.org/jira/browse/WEEX-474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16563088#comment-16563088 ] 

ASF GitHub Bot commented on WEEX-474:
-------------------------------------

YorkShen commented on issue #1292: [android][WEEX-474] when the app's WXInstance destroy, but Weex page call toast Toast ,crash
URL: https://github.com/apache/incubator-weex/pull/1292#issuecomment-409080495
 
 
   Seems like already merged

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Toast ,crash!
> -------------
>
>                 Key: WEEX-474
>                 URL: https://issues.apache.org/jira/browse/WEEX-474
>             Project: Weex
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 0.16, 0.18
>            Reporter: 武晨
>            Assignee: codefurture
>            Priority: Blocker
>             Fix For: 0.18
>
>
> 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
> { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); }
> catch (Exception e)
> { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); }
> }
>  if (TextUtils.isEmpty(message))
> { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; }
> if (duration > 3)
> { duration = Toast.LENGTH_LONG; }
> else
> { duration = Toast.LENGTH_SHORT; }
> if (toast == null) {
> {color:#ff0000}*//crash here!!!! sometime, mWXSDKInstance.getContext() is null  !!!!*{color}
>  t*oast = Toast.makeText(mWXSDKInstance.getContext(), message, duration);*
>  } else
> { toast.setDuration(duration); toast.setText(message); }
> 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!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)