小编Han*_*nut的帖子

将图像返回到whatsapp

当用户尝试使用whatsapp共享图像时,我一直在尝试构建一个显示为可选图像源的应用程序.到目前为止,我已经设法让我的应用程序显示在服务选择器中whatsapp使用intent过滤器启动但我无法让图像正确返回到whatsapp.我在下面发布我的代码:

public void returnImage(View v){
    //Bitmap img;
    //Bundle selectedImage = new Bundle();
    Uri imageURI;
    Intent shareIntent = new Intent();
    switch(v.getId()){
    case R.id.eric1 :
        imageURI =  saveToCache(R.drawable.cartman1);
        shareIntent.putExtra(Intent.EXTRA_STREAM, imageURI);
        shareIntent.setType("image/png");
        setResult(RESULT_OK, shareIntent);
        Utils.makeToast("Selected",this);
        System.out.println("--------------------------------");
        System.out.println(imageURI.toString());
        finish();
    }
}

   private Uri saveToCache(int resID) {
    // TODO Auto-generated method stub
    Bitmap image = BitmapFactory.decodeResource(getResources(), resID);
    File imageFile;
    Date d = new Date();
    String imgName = ((Long.toString(d.getTime())).subSequence(1,
            9)).toString();
    String state = Environment.getExternalStorageState();
    printDebug(state);
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        File file = getExternalFilesDir(null);
        if (file != null) …
Run Code Online (Sandbox Code Playgroud)

android image return-value android-intent whatsapp

4
推荐指数
1
解决办法
4680
查看次数

标签 统计

android ×1

android-intent ×1

image ×1

return-value ×1

whatsapp ×1