0
我能夠得到局部圖像的SD卡路徑,但無法使用像谷歌獲得路徑非本地圖像同步加,保管箱等如何從Google plus獲取圖片同步的SD卡路徑?
我的代碼如下: -
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v == imgSelectPhoto){
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(i, 0);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 0:
if(resultCode == RESULT_OK) {
try
{
DisplayImageOptions options;
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_stub)
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error).cacheInMemory()
.cacheOnDisc().bitmapConfig(Bitmap.Config.RGB_565).build();
imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(getApplicationContext()));
imageLoader.displayImage(data.getData().toString(), imgImagePreview, options);
//imgImagePreview.setImageURI(data.getData());
fileUrl = getRealPathFromURI(data.getData());
Log.w("TEST","ImageURI : "+ data.getData()+" Path : "+ fileUrl);
}
catch(Exception e)
{
}
objAdapter.InsertLocalImage(fieldNotes, displayName, fileLargerName, fileUrl)
}
}
}
public String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
logcat的: -
01-17 17:50:58.242: W/TEST(11961): ImageURI : content://com.sec.android.gallery3d.provider/picasa/item/5955342059370063154 Path : https://lh4.googleusercontent.com/-vAwMltvVVdE/UqWgDNyyJTI/AAAAAAAABtc/IiAikNj0uwI/I/20131209_162222.jpg
如果有人有想法,請回復。 在此先感謝...
感謝您的回覆。有沒有這方面的例子或鏈接? – jagdish
@jagdish:Android SDK中的['ContentResolver'是一個Java類](http://developer.android.com/reference/android/content/ContentResolver.html)。 ['openInputStream()'是該Java類的一個方法](http://developer.android.com/reference/android/content/ContentResolver.html#openInputStream(android.net.Uri))。 'openFileInput()'返回一個'InputStream',它是一個標準的Java I/O類。 – CommonsWare
謝謝@CommonsWare,我會看看這個。 – jagdish