2017-07-20 6 views
0

私は自分のアプリでデータをエクスポートしようとしています。私はそれを可能にするIntentを作成する方法を知っていますが、私が対処できないことは、私がリクエストに持っているBlob URLです。私はそれからイメージを得る方法を知らない。Androidでblob urlをインターセプトする方法は?

I/System.out: blob:null/f7da72d2-a7a7-4cb5-987b-d1e392a14bf1

そして、これはWebViewClientを拡張するクラスで、私の方法である:

@Override 
    public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { 


     if(request.getUrl() != null && request.getUrl().toString().startsWith("blob:")){ 
//This is my miserable attempt to do get the data from blob url.. 
      String stringURL = request.getUrl().toString(); 
      byte[] byteURL = stringURL.getBytes(); 
      Blob blob; 
      try { 
       blob.setBytes(1, byteURL); 
      } catch (SQLException e) { 
       e.printStackTrace(); 
      } 


//I will pass the data from blob here, this is just placeholder 
      Intent sendIntent = new Intent(); 
      sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      sendIntent.setAction(Intent.ACTION_SEND); 
      sendIntent.putExtra(Intent.EXTRA_TEXT, "Simple txt"); 
      sendIntent.setType("text/plain"); 
      view.getContext().startActivity(sendIntent); 
     } 


     return super.shouldInterceptRequest(view, request); 
    } 

答えて

0

私はJavaScriptInterface.classを使用して、このURLトラフJavaScriptを処理していたんでした何これはどのように見えるかです。まず、このURLのデータをスクリプトで取得する必要があります。このBLOBデータをBase64文字列で変換し、この文字列をJavaInterface.classに送信してから、この文字列で必要な処理を行います。このBase64文字列は ".pdf"ファイルにあります。私の答えを見てくださいhere

関連する問題