tweetinvi - 没有错误,没有推文

时间:2017-11-17 00:36:20

标签: c# twitter tweetinvi

我正在尝试发送带有磁盘映像的推文。我目前的代码如下:

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {

        final WebView.HitTestResult result = mWebView.getHitTestResult();
        if (result.getType() == WebView.HitTestResult.IMAGE_TYPE ||
                result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {

            //menu.setHeaderTitle(result.getExtra());
            menu.add(0, 1, 0, "Save Image")
                    .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem menuItem) {

                            String DownloadImageURL = result.getExtra();

                            if(URLUtil.isValidUrl(DownloadImageURL)){

                                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(DownloadImageURL));
                                request.allowScanningByMediaScanner();
                                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                                DownloadManager downloadManager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
                                downloadManager.enqueue(request);

                                Toast.makeText(getContext(),"Image save successfully.",Toast.LENGTH_SHORT).show();
                            }
                            else {
                                Toast.makeText(getContext(),"Error to save image.",Toast.LENGTH_SHORT).show();
                            }
                            return false;
                        }
                    });
        }
    }

代码似乎运行,没有返回异常,但是未发布推文。感谢任何帮助或见解。

1 个答案:

答案 0 :(得分:0)

请查看ExceptionHandler的文档:https://github.com/linvi/tweetinvi/wiki/Exception-Handling

ExceptionHandler.SwallowWebExceptions = false;

然后会引发异常。