Android 中的 Picasa 访问:PicasaUploadActivity

发布于 2024-08-20 07:11:00 字数 704 浏览 13 评论 0原文

我是 Android 新手,我正在努力弄清楚我可以使用哪些工具。 我现在正在针对 Android 2.0.1 进行开发,因为我的设备就是这样运行的。

具体来说,我正在编写一个应用程序,我想将图像上传到 Picasa 相册。我几乎可以肯定这是受支持的;例如,内置(Google?)照片查看器有一个带有 Picasa 选项的“共享”按钮,甚至还有一小部分示例代码,包括片段

[借用的代码!如果这违反了规则,我深表歉意..]

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

这看起来正是我想要的。

但我在任何地方都找不到任何文档。事实上我很不清楚如何使用这种类型的资源。在 Eclipse 中,我是否需要包含另一个项目 com.google.android.apps.uploader?如果是这样,我该如何获取它?我该如何包含它?有没有提供工作示例代码供我查看?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

本王不退位尔等都是臣 2024-08-27 07:11:00

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

}

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

}
梦中的蝴蝶 2024-08-27 07:11:00

请参阅 android 开发人员:picasa

我还没有找到任何文档,但您可以使用内置 picasa 应用(如果您
r 在 1.5 中工作)将照片上传到 picasa 网络相册,但一个
限制是你无法控制登录和注销......它
使用当前在手机上注册的Google帐户...如果您
有兴趣我可以给你 sm 示例代码...

所以没有文档,你只需 重用现有应用程序的 Activity

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文