Picasa access in android: PicasaUploadActivity

2019-01-22 23:47发布

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.

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

[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? If so, how do I get it? How do I include it? Is there any working sample code provided for me to peek at?

2条回答
虎瘦雄心在
2楼-- · 2019-01-23 00:09

see android-developers: picasa:

I havent found any docs, but u can make use of the built-in picasa app (if u r 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...

So there is no docs, you just Re-using an Activity of existing app.

查看更多
爷、活的狠高调
3楼-- · 2019-01-23 00:17

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

}
查看更多
登录 后发表回答