2017-09-01 85 views
1

我需要共享,一個外部圖像的URL與文字一起, 從web視圖,但由於某種原因,我得到各個畢加索覆蓋誤差共享圖像的URL +文字:的Android使用畢加索

已經實施的Android中的Javascript界面​​。

@JavascriptInterface 
    public void shareContent(String text, String imageURL){ 
     shareData(text, imageURL); 
    } 

錯誤,我得到:Method does not override method from its superclass

public void shareData(String url) { 
    Picasso.with(getApplicationContext()).load(url).into(new AppLink.Target() { 
     @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { 
      Intent i = new Intent(Intent.ACTION_SEND); 
      i.setType("image/*"); 
      i.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bitmap)); 
      startActivity(Intent.createChooser(i, "Share Image")); 
     } 
     @Override public void onBitmapFailed(Drawable errorDrawable) { } 
     @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } 
    }); 
} 

並獲取本地保存的圖像

public Uri getLocalBitmapUri(Bitmap bmp) { 
    Uri bmpUri = null; 
    try { 
     File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "share_image_" + System.currentTimeMillis() + ".png"); 
     FileOutputStream out = new FileOutputStream(file); 
     bmp.compress(Bitmap.CompressFormat.PNG, 90, out); 
     out.close(); 
     bmpUri = Uri.fromFile(file); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    return bmpUri; 
} 
+0

如何這是不是重複? https://stackoverflow.com/questions/23681177/picasso-load-image-from-filesystem –

+0

我是。您正在從磁盤讀取文件,然後調用共享意圖。不知道爲什麼畢加索甚至在這裏需要 –

+0

爲了表現。 – Isabelle

回答

0

貌似你試圖執行畢加索的方式方法,但你實際做的Applink.Target

into(new AppLink.Target() { 

我認爲你正在尋找這個

into(new com.squareup.picasso.Target() { 
+0

剛剛發現,謝謝mate :) - 導入是錯誤的,從畢加索導入後,我只有:new Target() – Isabelle