如何从谷歌的App Engine显示Android应用程序的图片? [英] how to display images in android application from Google App Engine?

查看:112
本文介绍了如何从谷歌的App Engine显示Android应用程序的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我新的Andr​​oid开发,我要开发的应用程序中,谷歌应用程序引擎是参与。我想要做的就是我要来从谷歌应用程序引擎的云图像,并显示在android应用。我不能把它拿来的图像从云到Android。

As I new to android development, I have to develop application in which, Google app engine is involved. What I want to do is I want to fetch the images from Google app engine cloud and show it in android application. I am not able to fetch it that image from cloud to android.

请帮忙...

谢谢

推荐答案

您可以使用谷歌云端点的从数据存储发送数据,包括存储在blobproperty图像,为您的Andr​​oid客户端,然后显示出来。你可以在谷歌的云计算终端的详细信息,其中也有样本code和其他SO线程了解如何根据终端的设置,通过REST API Android和应用程序引擎数据存储之间的通信读取。我加入下面的详细信息只为blobproperty,因为它没有在文件中提到的细节:

You can utilize Google Cloud Endpoints for sending data from your datastore, including images stored in blobproperty, to your android client and then display them. You can read upon the details of google cloud endpoints , which also has the sample code and other SO threads for understanding how to setup communication between android and appengine datastore through rest api based on endpoints. I am adding below the details only for blobproperty as it is not mentioned in detail in the document :

1,要发送blobproperty通过终点,你需要使用<一个href="http://stackoverflow.com/questions/15576203/read-image-into-protorpc-message-thru-endpoints-api">BytesField在protorpc 将自动发送的知情同意为的base64 EN codeD

1, For sending blobproperty through endpoints, you need to use BytesField in protorpc which will automatically send the pic as base64 encoded

2,在Android中,你定义一个字符串属性,通过终端接收消息的bytesfield数据

2, In android , you define a string property to receive the bytesfield data in the message through endpoints

@com.google.api.client.util.Key
    private String pic;

3,如果您在Android中使用SQLite在本地存储接收到的图像,你应该使用BLOB类型的PIC列 C_PIC +一滴键,可以插入接受字符串值到这个

3, If you are using sqlite in android to locally store the received image, you should use blob type for the pic column C_PIC +" blob and you can insert the received string value into this

4,而来自Android的SQLite数据库读取显示,您可以在PIC存储到一个byte [],然后去$ C C中的Base64 EN codeD PIC作为另一个字节$ [],然后将其转换成位图和使用合适imageview的显示它

4,While reading from android's sqlite database for displaying, you can store the pic into a byte[] and then decode the base64 encoded pic as another byte[] and then convert it into a bitmap and display it using a suitable imageview :

byte[] picblob = cursor.getBlob(cursor.getColumnIndex(Yourdatabase.C_PIC));

if (picblob!=null){
                byte[] decodedString = Base64.decode(picblob, Base64.DEFAULT);
               Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);

        ((ImageView)view).setImageBitmap(decodedByte);
}

这篇关于如何从谷歌的App Engine显示Android应用程序的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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