Monday 15 July 2013

java - The usual Twitt_Sharing class giving error -



java - The usual Twitt_Sharing class giving error -

here class:

package com.twitter.android; import java.io.file; import twitter4j.statusupdate; import twitter4j.twitter; import twitter4j.twitterexception; import android.app.activity; import android.app.progressdialog; import android.os.asynctask; import android.util.log; import android.widget.toast; import com.twitter.android.twitter_handler.twdialoglistener; public class twitt_sharing { private final twitter_handler mtwitter; private final activity activity; private string twitt_msg; private file image_path; public twitt_sharing( activity act, string consumer_key, string consumer_secret ) { this.activity = act; mtwitter = new twitter_handler(activity, consumer_key, consumer_secret); } public void sharetotwitter(string msg, file image_url) { this.twitt_msg = msg; this.image_path = image_url; mtwitter.setlistener(mtwlogindialoglistener); if (mtwitter.hasaccesstoken()) { // post info in asyn background thread showtwittdialog(); } else { mtwitter.authorize(); } } private void showtwittdialog() { new posttwitttask().execute(twitt_msg); } private final twdialoglistener mtwlogindialoglistener = new twdialoglistener() { @override public void onerror(string value) { activity.runonuithread(new runnable() { @override public void run() { // todo auto-generated method stub showtoast("login failed"); mtwitter.resetaccesstoken(); } }); } @override public void oncomplete(string value) { showtwittdialog(); } }; void showtoast(final string msg) { activity.runonuithread(new runnable() { @override public void run() { toast.maketext(activity, msg, toast.length_short).show(); } }); } class posttwitttask extends asynctask<string, void, string> { progressdialog pdialog; @override protected void onpreexecute() { pdialog = new progressdialog(activity); pdialog.setmessage("posting twitt..."); pdialog.setcancelable(false); pdialog.show(); super.onpreexecute(); } @override protected string doinbackground(string... twitt) { seek { // mtwitter.updatestatus(twitt[0]); // file imgfile = new file("/sdcard/bluetooth/baby.jpg"); homecoming share_pic_text_titter(image_path, twitt_msg, mtwitter.twitterobj); } grab (exception e) { if (e.getmessage().tostring().contains("duplicate")) { homecoming "posting failed because of duplicate message..."; } e.printstacktrace(); homecoming "posting failed!!!"; } } @override protected void onpostexecute(final string result) { super.onpostexecute(result); pdialog.dismiss(); if (null != result && result.equals("success")) { activity.runonuithread(new runnable() { @override public void run() { // todo auto-generated method stub showtoast(result); } }); } } } public string share_pic_text_titter(file image_path, string message, twitter twitter) throws exception { string status = ""; seek { statusupdate st = new statusupdate(message); --------------------------**error in line below**-------------------------------- st.setmedia(image_path); twitter.updatestatus(st); activity.runonuithread(new runnable() { @override public void run() { // todo auto-generated method stub toast.maketext(activity, "successfully update on twitter...!", toast.length_short).show(); } }); status = "success"; /* * toast.maketext(activity, "successfully update on twitter...!", * toast.length_short).show(); */ } grab (twitterexception e) { status = "fail"; log.v("log_tag", "pic upload error" + e); activity.runonuithread(new runnable() { @override public void run() { // todo auto-generated method stub toast.maketext(activity, "ooopss..!!! failed update on twitter.", toast.length_short).show(); } }); } homecoming status; } public void authorize_userdetail() { } }

now in line st.setmedia(image_path); showing error states method setmedia(file) undefined type statusupdate has ever faced this.?

according documentation, method setmedia(file file) available in twitter 4j v2.2.5+ unable find method in versions below this.

updating newer version solves problem.

java android twitter twitter4j

No comments:

Post a Comment