我正在学习从Android手机向web服务器发送图片的教程。教程在这里:
http://blog.sptechnolab.com/2011/03/09/android/android-upload-image-to-server/
不幸的是,当我将java代码粘贴到我的文件中时,我遇到了一些错误:
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.a1);
// a1 cannot be resolved or is not a field还有这个:
String ba1 = Base64.encodeBytes(ba);
// The method encodeBytes(byte[]) is undefined for the type Base64我已经进一步阅读了评论,他们说我应该用下面的代码替换后面的代码:
String ba1 = Base64.encodeToString(ba, 0);但是这仍然不起作用,它说其中有一个额外的值(删除额外的值仍然需要我通过Eclipse的错误系统将一个值更改为'static‘。
我已经阅读了下面博客上的所有评论,并尝试了补救措施,但似乎都不起作用。有没有人知道问题出在哪里,或者有没有我可以导入的库(我该如何导入它?)
发布于 2012-11-30 18:01:01
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.a1);首先,您应该有一个名为a1的可绘制文件(例如,a1.png,a1.jpg,...)在你的可抽屉文件夹里。
String ba1 = Base64.encodeBytes(ba);
// The method encodeBytes(byte[]) is undefined for the type Base64请参考此链接,Base64类中没有这样的方法。http://developer.android.com/reference/android/util/Base64.html
试着这样做:
int flag = 0; // you can pass the default 0 = Base64.DEFAULT
String ba1 = Base64.encodeToString(ba, flag);https://stackoverflow.com/questions/13642656
复制相似问题