English 中文(简体)
缩略图和从 ICS 上的画廊采集 picasa 图像
原标题:Thumbnails and picking picasa images from gallery on ICS

我很难找到缩略图。 和Thumbnail合作, 在运行 ICS 的 Nexus S 上用 Picasa 照片。 其他一切似乎都有效, 包括从 Picasa 获取原始图像并展示, 但让Thumbnail 似乎不起作用 。 我试图使用时有以下错误 :

E/MiniThumbFile( 1852): Got exception when reading magic, id = 5745625138093120418, disk full or mount read-only? class java.lang.IllegalArgumentException
W/MediaProvider(  540): original media doesn t exist or it s canceled.

磁盘不满,是读写功能,应用程序有外部存储写权限,照片确实存在于picasa上(我可以通过机器人画廊应用程序查看)。

Android 2.3的代码也很好, 但是它遵循了一种略微不同的路径, 因为2.3似乎下载了照片的副本, 并将实际的本地文件 / uri 交给您到新下载的图像上, 而不是给你内容 / uri 。

这是该代码的主要肉类:

  public void addImage(Uri uri, boolean local)
  {
     ContentResolver resolver = getContentResolver();
     Uri actualUri = uri;

     Log.d(TAG, "addImage: original uri: " + uri.toString());

     if(local) {
        try {
           List<String> uriPath = uri.getPathSegments();
           String contentUri = Media.insertImage(resolver, uri.getPath(), uriPath.get(uriPath.size()-1), new String());
           actualUri = Uri.parse(contentUri);
        }
        catch(java.io.FileNotFoundException ex) {
           Log.e(TAG, "FileNotFoundException: ");
           ex.printStackTrace();
        }
     }

     Log.d(TAG, "addImage: actual uri: " + actualUri.toString());

     List<String> uriPath = actualUri.getPathSegments();
     long imageId = Long.parseLong(uriPath.get(uriPath.size() -1));

     Bitmap thumb = Thumbnails.getThumbnail(resolver, imageId, Thumbnails.MINI_KIND, null);
     if(thumb == null) {
        Log.e(TAG, "Failed to get thumbnail for our image.");
        Toast toast = Toast.makeText(getApplicationContext(), "Failed to get thumbnail for image. Please try again.", Toast.LENGTH_SHORT);
        toast.show();
        return;
     }

     uris.add(uri);
     bmps.add(thumb);
     notifyDataSetChanged();
  }

当应用程序“ 收集” 照片时, 将新照片添加到“ 收集” 照片中, 即使用此方法。 当它已知为本地图像时( 即: 如果照片来自应用程序内部, 或“ 活动Result s ” 数据参数为空), 本地参数将设定为真实, 我试图从媒体内容提供商处获取一个内容:// uri 回来, 这样我们就可以从一个有效的图像id 传递到 Thumbnails. getThumbnail 。 该代码对来自相机应用程序( 启动 ActionivityForResult) 的图像以及存储在本地设备上的图片库的图像非常有效 。

我有点醉了

问题回答

https:// developmenters.google.com/picasa-web/docs/2.0/reference#media_group" rel=“没有跟随 no follown noreferrer>>https://developers.google.com/picasa-web/docs/2.0/reference#media_group

If you are having a hard time in android getting to the thumbnails, note the above link and api and the media:group/media:thumbnail tag in the atom feed. Thats the parent element or the container of the thumbnails refered to in this post

所以,为了处理鼠拇指和机器人, 如果您可以构建您的代码来实际使用 api( picasa feed / photo/ media: group etc.), 您可能没有像当前这样的错误问题 。

样本google/和机器人/和/picasa < a href="http://code.google.com/p/gdata-java-client/source/browse/tags/2.2.1-alpha/sample/picasa/picasa-atom-android-sample/src/com/google/api/data/sample/picasa/PicasaAtomAndroidSample.java" rel=“无尾随的鼻孔” >代码

"http://code.google.com/p/google-api-java-client/" rel="不跟随 noreferrer" >api ref

""http://code.google.com/p/gdata-java-client/ downloads/list" rel="不跟随 noreferrer" > 另1pi ref

存在同样的问题,也是一个进口/包装问题。

一定要使用正确的缩略图类。 有两个。 一个用于视频, 一个用于图像 。

MediaStore.Images.Thumbnails
MediaStore.Video.Thumbnails




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签