ユーザーが[フレンドとユーザー]ウォールに画像とともにメッセージを投稿できるようにするプログラムを作成しています.SDカード画像を使用して投稿していますが、SDカードの代わりにフィードダイアログが表示されるたびに画像リンクパラメータでwww.google.comを使用したため、Googleのロゴを取得しているため、その画像を選択しています。以下を参照してください。
他のウェブリンクをいくつか試してみたところ、そのリンクから画像が選択されていることがわかりました....
だからここで私の質問、なぜSDカードのイメージがそこにないのですか
public void onItemClick(AdapterView<?> adapterView, View view,
final int position, long id) {
try {
friendId = jsonArray.getJSONObject(position).getLong("uid");
String name = jsonArray.getJSONObject(position).getString("name");
new AlertDialog.Builder(this)
.setTitle(R.string.post_on_wall_title)
.setMessage(
String.format(getString(R.string.post_on_wall),
name)).setPositiveButton(R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
try
{
String myPath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/Pictures/Facebook/flower1.jpg";
File f = new File(myPath);
FileInputStream fis = new FileInputStream(f);
Log.d("onItemClick", "fis ::--" + fis);
Bitmap bi = BitmapFactory.decodeStream(fis);
Log.d("onItemClick", "bi ::--" + bi);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Log.d("onItemClick", "baos ::--" + baos);
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Log.d("onItemClick", "data ::--" + data);
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.d("onCreate", "debug error e = " + e.toString());
}
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("method", "photos.upload");
params.putByteArray("picture", data);
Log.d("onItemClick", "params.putByteArray ::--" + data);
params.putString("name", getString(R.string.app_action));
FacebookUtility.facebook.dialog(FriendsList.this, "feed",
params, (DialogListener) newPostDialogListener());
}
}).setNegativeButton(R.string.no, null).show();
} catch (JSONException e) {
showToast("Error: " + e.getMessage());
}
}
マニフェストでこれらの許可も与えています。
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />