Android twitter tweet con imagen

Posible duplicado:
¿Podemos publicar una imagen en twitter utilizando la API de twitter en Android?

Estoy trabajando en una aplicación de Android y quiero tweetear un mensaje y una imagen para twitter. Soy capaz de tweet sólo tweets a twitter por el código:

String token = prefs.getString(OAuth.OAUTH_TOKEN, ""); String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, ""); AccessToken a = new AccessToken(token, secret); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET); twitter.setOAuthAccessToken(a); try { **twitter.updateStatus("New tweet");** twitter.//Which property of twitter should I use to tweet an image and //message } catch (TwitterException e) { // TODO Auto-generated catch block Log.e("Errorssssssssssssss", e.toString()); } 

¿Cómo puedo incluir una imagen también?

Consulte http://www.londatiga.net/it/how-to-post-twitter-status-from-android/ , utilice la biblioteca twitter4j

 public void uploadPic(File file, String message) throws Exception { try{ StatusUpdate status = new StatusUpdate(message); status.setMedia(file); mTwitter.updateStatus(status);} catch(TwitterException e){ Log.d("TAG", "Pic Upload error" + e.getErrorMessage()); throw e; } } 

Donde mTwitter es una instancia de la clase Twitter

Asegúrese de que está utilizando la última versión del archivo jar twitter4j-core.

U puede probar ejemplo que viene con Twitter4j Library.Following código le ayudará u

 public final class TwitpicImageUpload { /** * Usage: java twitter4j.examples.media.TwitpicImageUpload [API key] [message] * * @param args message */ public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: java twitter4j.examples.media.TwitpicImageUpload [API key] [image file path] [message]"); System.exit(-1); } try { Configuration conf = new ConfigurationBuilder().setMediaProviderAPIKey(args[0]).build(); ImageUpload upload = new ImageUploadFactory(conf).getInstance(MediaProvider.TWITPIC); String url; if (args.length >= 3) { url = upload.upload(new File(args[1]), args[2]); } else { url = upload.upload(new File(args[1])); } System.out.println("Successfully uploaded image to Twitpic at " + url); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to upload the image: " + te.getMessage()); System.exit(-1); } } } 

Descargue la biblioteca de Twitter4j busque más ejemplos allí.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.