我试图写在Android 2.2的目标一个Twitter应用程序(使用一些样本code,我在网上找到并使用马尔科Gargenta的奥赖利文本)。我坚持这个问题下面在日志中。该人士$ C $ C被首次随后日志。任何想法是怎么回事错在这里?也没有任何人有或者可以指向一个样本jtwitter code在Android上工作。
谢谢,拉维
保护字符串doInBackground(字符串...状态){ 尝试{ // Autho信息 / * OAuthSignpostClient oauthclient =新OAuthSignpostClient(cons_key, cons_secret,的access_token,access_secret); * / OAuthSignpostClient oauthclient =新OAuthSignpostClient(ACCESS_TOKEN,access_secret,OOB); // ***的张贴到Twitter当前没有使用这一界面上工作 叽叽喳喳=新的Twitter(mytwitterusername,oauthclient); //twitter.setAPIRootUrl(\"http://learningandroid.status.net/api); // ***的张贴到Twitter当前没有使用这一界面上工作 Log.i(Logtag,状态目前为+状态[0]); Twitter.Status状态= twitter.updateStatus(状态[0]); //返回status.text; 返回状态[0]; }赶上(TwitterException E){ Log.e(Logtag,e.toString()); e.printStackTrace(); 返回无法投递到Twitter }
}
E / dalvikvm(719):找不到方法javax.swing.JOptionPane.showInputDialog,从方法winterwell.jtwi引用tter.OAuthSignpostClient.askUserW / dalvikvm(719):VFY:无法解析静态方法443:Ljavax /秋千/ JOptionPane的; .showInputDialog(Ljava /朗/ Objec吨;)Ljava /朗/字符串;W / dalvikvm(719):VFY:在拒绝运code 0x71为0x0000W / dalvikvm(719):VFY:拒绝Lwinterwell / jtwitter / OAuthSignpostClient; .askUser(Ljava /朗/字符串;)Ljava /朗/〜应变G;W / dalvikvm(719):验证拒绝类Lwinterwell / jtwitter / OAuthSignpostClient;W / dalvikvm(719):主题ID = 17:螺纹未捕获的异常退出(组= 0x4000fe70)E / AndroidRuntime(719):未捕获的处理程序:螺纹的AsyncTask#1退出,由于未捕获的异常E / AndroidRuntime(719):了java.lang.RuntimeException:执行doInBackground发生错误()E / AndroidRuntime(719):在android.os.AsyncTask $ 3.done(AsyncTask.java:200)E / AndroidRuntime(719):在java.util.concurrent.FutureTask中$ Sync.innerSetException(FutureTask.java:234)E / AndroidRuntime(719):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:258)E / AndroidRuntime(719):在java.util.concurrent.FutureTask.run(FutureTask.java:122)E / AndroidRuntime(719):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.runTask(ThreadPoolExecutor.java:648)E / AndroidRuntime(719):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:673)E / AndroidRuntime(719):在java.lang.Thread.run(Thread.java:1058)E / AndroidRuntime(719):java.lang.VerifyError:产生的原因winterwell.jtwitter.OAuthSignpostClientE / AndroidRuntime(719):在com.ravi.tweeto.StatusActivity $ PostToTwitter.doInBackground(StatusActivity.java:81)E / AndroidRuntime(719):在com.ravi.tweeto.StatusActivity $ PostToTwitter.doInBackground(StatusActivity.java:1)E / AndroidRuntime(719):在android.os.AsyncTask $ 2.call(AsyncTask.java:185)E / AndroidRuntime(719):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:256)E / AndroidRuntime(719):... 4个I /处理(585):发送信号。 PID:719 SIG:3I / dalvikvm(719):主题ID = 7:反应以信号3I / dalvikvm(719):写堆栈跟踪/data/anr/traces.txt----
解决方案
基本上JTwitter库已不在Android SDK的,因为它没有使用Swing的Java Swing类的调用。我不得不为JTwitter源并取出摆code我的应用程序工作。希望这有助于。
I am trying to write a twitter application on Android target 2.2 (using some sample code that I found on the net and using Marko Gargenta's O'Reilly text). I am stuck with the problem as in the log below. The source code is given first followed by the log. Any idea what's going wrong here ? Also does anyone have or can point to a sample jtwitter code working on Android.
Thanks, Ravi
protected String doInBackground(String... statuses) {
try {
//Autho information
/*OAuthSignpostClient oauthclient = new OAuthSignpostClient(cons_key,
cons_secret, access_token, access_secret);*/
OAuthSignpostClient oauthclient = new OAuthSignpostClient(access_token, access_secret,"oob");
//***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
twitter = new Twitter(mytwitterusername, oauthclient);
//twitter.setAPIRootUrl("http://learningandroid.status.net/api");
//***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
Log.i(Logtag, "Status currently is " + statuses[0]);
Twitter.Status status = twitter.updateStatus(statuses[0]);
//return status.text;
return statuses[0];
} catch (TwitterException e) {
Log.e(Logtag, e.toString());
e.printStackTrace();
return "Failed to post to Twitter";
}
}
E/dalvikvm( 719): Could not find method javax.swing.JOptionPane.showInputDialog, referenced from method winterwell.jtwi
tter.OAuthSignpostClient.askUser
W/dalvikvm( 719): VFY: unable to resolve static method 443: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Objec
t;)Ljava/lang/String;
W/dalvikvm( 719): VFY: rejecting opcode 0x71 at 0x0000
W/dalvikvm( 719): VFY: rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/Strin
g;
W/dalvikvm( 719): Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
W/dalvikvm( 719): threadid=17: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 719): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime( 719): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 719): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 719): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:234)
E/AndroidRuntime( 719): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:258)
E/AndroidRuntime( 719): at java.util.concurrent.FutureTask.run(FutureTask.java:122)
E/AndroidRuntime( 719): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
E/AndroidRuntime( 719): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
E/AndroidRuntime( 719): at java.lang.Thread.run(Thread.java:1058)
E/AndroidRuntime( 719): Caused by: java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
E/AndroidRuntime( 719): at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:81)
E/AndroidRuntime( 719): at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:1)
E/AndroidRuntime( 719): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime( 719): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
E/AndroidRuntime( 719): ... 4 more
I/Process ( 585): Sending signal. PID: 719 SIG: 3
I/dalvikvm( 719): threadid=7: reacting to signal 3
I/dalvikvm( 719): Wrote stack trace to '/data/anr/traces.txt'
----
解决方案
Basically the JTwitter library has calls to Java swing classes that are not in the Android SDK as it does not use swing. I had to get the source for JTwitter and remove the swing code for my application to work. Hope this helps.