本文介绍了android 新手 - 如何使用 'uploadImage'在 SocialAuthAdapter 类中找到的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图片上传到 Twitter.SocialAuthAdapter 类 包含一个应该执行此操作的uploadImage"方法.

I am trying to upload an image to twitter. SocialAuthAdapter class contains an 'uploadImage' method which should do it.

这是我的代码:

public void post_image(){
File imgFile = new  File("/storage/sdcard0/pic_app/ubgthyghu.com2013923.png");
bitmap2 = decodeFile(imgFile); //this just brings back a resized bitmap, it works.. i  tested it
try {
Log.d(tag,"********************* picture is going to be updated...");
int returnvalue  = adapter.uploadImage("fred", "ubgthyghu.com2013923.png", bitmap2, 3);
Log.d(tag,"here is the return value:  " + returnvalue );
} catch (Exception e) {Log.d(tag,"u got an error haus");  e.printStackTrace();}
}//post_image

但是我收到以下消息:

09-27 07:39:16.280: D/ShareButtonActivity(11622): ********************* picture is going to be updated...
09-27 07:39:16.400: D/dalvikvm(11622): GC_CONCURRENT freed 424K, 10% free 12775K/14151K, paused 11ms+1ms, total 19ms
09-27 07:39:16.400: D/dalvikvm(11622): WAIT_FOR_CONCURRENT_GC blocked 7ms
09-27 07:39:16.400: I/TwitterImpl(11622): Uploading Image :: ubgthyghu.com2013923.png, message :: fred
09-27 07:39:16.405: D/ShareButtonActivity(11622): u got an error haus
09-27 07:39:16.405: W/System.err(11622): org.brickred.socialauth.exception.SocialAuthException: Image Upload Error
09-27 07:39:16.405: W/System.err(11622): at org.brickred.socialauth.android.SocialAuthAdapter.uploadImage(SocialAuthAdapter.java:1137)
09-27 07:39:16.405: W/System.err(11622): at com.example.twitter_stuff.ShareButtonActivity.post_image(ShareButtonActivity.java:273)
09-27 07:39:16.405: W/System.err(11622): at com.example.twitter_stuff.ShareButtonActivity$ResponseListener$1.onClick(ShareButtonActivity.java:171)
09-27 07:39:16.405: W/System.err(11622): at android.view.View.performClick(View.java:4223)
09-27 07:39:16.405: W/System.err(11622): at android.view.View$PerformClick.run(View.java:17281)
09-27 07:39:16.405: W/System.err(11622): at android.os.Handler.handleCallback(Handler.java:615)
09-27 07:39:16.405: W/System.err(11622): at android.os.Handler.dispatchMessage(Handler.java:92)
09-27 07:39:16.405: W/System.err(11622): at android.os.Looper.loop(Looper.java:137)
09-27 07:39:16.405: W/System.err(11622): at android.app.ActivityThread.main(ActivityThread.java:4898)
09-27 07:39:16.405: W/System.err(11622): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 07:39:16.410: W/System.err(11622): at java.lang.reflect.Method.invoke(Method.java:511)
09-27 07:39:16.410: W/System.err(11622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
09-27 07:39:16.410: W/System.err(11622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
09-27 07:39:16.410: W/System.err(11622): at dalvik.system.NativeStart.main(Native Method)
09-27 07:39:16.440: D/SocialAuthError(11622): org.brickred.socialauth.exception.SocialAuthException: Failed to update status on http://api.twitter.com/1.1/statuses/update.json?status=hjjhhj. Status :403
09-27 07:39:16.440: D/ShareButton(11622): Authentication Error: Message Not Posted
09-27 07:39:16.455: D/SocialAuthError(11622): org.brickred.socialauth.exception.SocialAuthException: Failed to update status on http://api.twitter.com/1.1/statuses/update.json?status=hjjhhj. Status :403
09-27 07:39:16.455: D/ShareButton(11622): Authentication Error: Message Not Posted

我知道准备起来很麻烦 - 抱歉,需要修复的主要代码是这样的:

I know that is quite messy to ready - sorry but the main code from it which needs to be fixed is this:

int returnvalue  = adapter.uploadImage("fred", "ubgthyghu.com2013923.png", bitmap2, 3);

推荐答案

使用 adapter.uploadImageAsync您正在隐式地对 main ui 威胁 执行 http 操作.Android 不喜欢那样

Use adapter.uploadImageAsyncYou are implicity performing a http action on the main ui threat. Android doesnt like that

这篇关于android 新手 - 如何使用 'uploadImage'在 SocialAuthAdapter 类中找到的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 23:58