2017-09-01 95 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