在机器人的Picasa访问:PicasaUploadActivity [英] Picasa access in android: PicasaUploadActivity

查看:142
本文介绍了在机器人的Picasa访问:PicasaUploadActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid,和我挣扎弄清楚到底是什么工具可以给我。 我正在开发针对Android 2.0.1现在,只因为那是我的设备上运行的内容。

I am new to Android, and I'm struggling to figure out exactly what tools are available to me. I am developing for Android 2.0.1 for now, just because that is what my device runs.

具体,我写一个应用程序,我想上传图片到的Picasa相册 。我几乎可以肯定,这是支持的;例如,内置的(谷歌?)照片浏览器有一个分享按钮,用Picasa的选项,甚至一个小一点的样本code,其中包括段

Specifically, I am writing an app that I would like to upload images to a Picasa album. I am almost sure this is supported; for example, the built in (Google?) photo viewer has a 'share' button with a Picasa option, and even a small bit of sample code, including the snippet

[借来的code!道歉,如果这是违反规则..]

temp.setComponent(new ComponentName 
("com.google.android.apps.uploader", 
"com.google.android.apps.uploader.picasa.PicasaUploadActivity")); 
startActivityForResult(temp, PICASA_INTENT) 

看起来像正是我想要的。

which looks like exactly what I want.

但我找不到任何文档的任何地方。我其实还不是很清楚如何使用此类型的资源。在Eclipse中,我需要有另外一个项目, com.google.android.apps.uploader ?如果是这样,我怎么得到它?我如何包括它?有没有为我提供任何工作示例code偷看?

But I can't find any documentation anywhere. I am in fact quite unclear how to use this type of resource. From within Eclipse, do I need to include another project, com.google.android.apps.uploader? If so, how do I get it? How do I include it? Is there any working sample code provided for me to peek at?

推荐答案

视频<一href="http://www.google.com/events/io/2011/sessions/best-practices-for-accessing-google-apis-on-android.html"相对=nofollow>谷歌I / O 2011 - (。第40分钟)在Android 的访问谷歌API的最佳实践

video Google I/O 2011 - Best practices for Accessing Google APIs on Android (40th min.)

public class PostPhotoActivity extends Activity
{

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    try
    {
        HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory();
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        InputStreamContent content = new InputStreamContent();
        ContentResolver contentResolver = getContentResolver();
        Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
        content.inputStream = contentResolver.openInputStream(uri);
        Cursor cursor = contentResolver.query(uri, null, null, null, null);
        cursor.moveToFirst();
        content.type = intent.getType();
        content.length = cursor.getLong(cursor.getColumnIndexOrThrow(Images.Media.SIZE));
        HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(
            "https://picasaweb.google.com/data/feed/api/user/default/albumid/default"), content);
        GoogleHeaders headers = new GoogleHeaders();
        request.headers = headers;
        String fileName = cursor.getString(cursor.getColumnIndexOrThrow(Images.Media.DISPLAY_NAME));
        headers.setSlugFromFileName(fileName);
        request.execute().ignore();
    }
    catch (IOException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}

这篇关于在机器人的Picasa访问:PicasaUploadActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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