简体   繁体   English

Android中的Picasa访问:PicasaUploadActivity

[英]Picasa access in android: PicasaUploadActivity

I am new to Android, and I'm struggling to figure out exactly what tools are available to me. 我是Android的新手,我正在努力弄清楚究竟有哪些工具可供我使用。 I am developing for Android 2.0.1 for now, just because that is what my device runs. 我正在为Android 2.0.1开发,因为这是我的设备运行。

Specifically, I am writing an app that I would like to upload images to a Picasa album. 具体来说,我正在编写一个应用程序,我想将图像上传到Picasa相册。 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 例如,内置(谷歌?)照片查看器有一个带有Picasa选项的“共享”按钮,甚至还有一小部分示例代码,包括代码段

[borrowed code! [借用代码! apologies if this is against the rules..] 如果这是违反规则的道歉..]

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. 这看起来就像我想要的。

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 ? 在Eclipse中,我是否需要包含另一个项目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? 是否有任何可用的示例代码供我查看?

video Google I/O 2011 - Best practices for Accessing Google APIs on Android (40th min.) 视频Google I / O 2011 - 在Android上访问Google API的最佳做法 (第40分钟)

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();
    }
}

}

see android-developers: picasa : android-developers:picasa

I havent found any docs, but u can make use of the built-in picasa app (if ur workin in 1.5) to upload ur photos to picasa web albums, but one limitation is that u dont hv the control of signing in and signing out... it uses the google account registered with the phone curently... if ur interested i can give u sm sample codes... 我没有找到任何文档,但你可以利用内置的picasa应用程序 (如果你的工作在1.5)将你的照片上传到picasa网络相册,但一个限制是你没有控制登录和退出...它使用手机注册的谷歌帐户...如果你感兴趣我可以给你sm样本代码...

So there is no docs, you just Re-using an Activity of existing app. 因此,没有文档,您只需重新使用现有应用的活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM