如何让用户使用SD卡的文件夹后的图像上墙 [英] How to allow user to post an Image on Wall using SDCard Folder

查看:188
本文介绍了如何让用户使用SD卡的文件夹后的图像上墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许用户的发布的消息对他们的[朋友及放大器;用户]长城的沿的单静态图片的,因为这个形象我使用的网络图片的URL

I am allowing user to post a message on their [Friend & User] Wall along with single static image, and for that image i am using Web Image URL

但现在我想的允许用户选择多个图像的任何单个图像的,就像存储在特定的文件夹中的 SD卡,然后发表10张沃尔的。

But now i wish to allow user to choose any single image from multiple images, like 10 images stored in a particular folder in SDCard, and then post to Wall.

因此,这里是我的问题,怎么办?

我现有的code到华尔街 发表静态图片,阅读下面的:

My existing code to post static image on Wall, read below:

@Override
public void onClick(DialogInterface dialog, int which) {

        Bundle params = new Bundle();
            params.putString("to", String.valueOf(friendId));
        params.putString("caption", getString(R.string.app_name));
        params.putString("description", getString(R.string.app_desc));
        params.putString("link", "http://www.google.com");
            params.putString("picture",FacebookUtility.HACK_ICON_URL);
            params.putString("name",getString(R.string.app_action));

            FacebookUtility.facebook.dialog(FriendsList.this,
           "feed", params, (DialogListener) new PostDialogListener());
      }
  }).setNegativeButton(R.string.no, null).show();
 } catch (JSONException e) {
      showToast("Error: " + e.getMessage());
}

FacebookUtility.java: -

public static final String HACK_ICON_URL = "http://2.bp.blogspot.com/-WuasmTMjMA4/TY0SS4TzIMI/AAAAAAAAFB4/6alyfOzWsqM/s320/flowers-wallpapers-love-blooms-roses-bunch-of-flowers.jpg";

检查我的应用程序的现有屏幕,

正如你可以看到上面的画面,我只显示一个静态图像正如我上面写的,但是现在我想允许用户使用SD卡来选择多个图像的图像,我的SD卡路径的这样的: / SD卡/ FbImages /

现在我想知道如何放置在上面的屏幕按钮[因为我没有使用任何自定义XML对于这一点,这是本土特色的FacebookSDK]

now i want to know how to place button in above screen [because i am not using any custom xml for this, that's native feature in FacebookSDK]

因此​​,这里是我的问题的如何打开SD卡文件夹,以及如何选择单张图像后,从多张图片

So here is my question how to open sdcard folder and how to choose single image to post from multiple images

推荐答案

你必须找到路径的形象。

you have to find path for that image.

试试下面的code选择图像

try following code to select image

btnSelect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
             Intent intent = new Intent();
             intent.setType("image/*");
             intent.setAction(Intent.ACTION_GET_CONTENT);
             startActivityForResult(Intent.createChooser(intent,"Select Picture"), 0);
        }
    });

获取路径selectd图片

get path for selectd image

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == 0) {
            Uri selectedImageUri = data.getData();
            selectedImagePath = getPath(selectedImageUri);
            System.out.println("Image Path : " + selectedImagePath);

        }
    }
}

public String getPath(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}

然后用

  params.putString("picture",selectedImagePath);

这篇关于如何让用户使用SD卡的文件夹后的图像上墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆