Posted By

ralph on 12/25/08


Tagged

twitter android twidroid public intent


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bzibble
Krispin


Use Twidroid's public intent to send Twitter messages from your own Android application


 / Published in: Java
 

URL: http://www.twidroid.com

  1. public void onCreate(Bundle savedInstanceState) {
  2. super.onCreate(savedInstanceState);
  3. setContentView(R.layout.main);
  4.  
  5. final Button button = (Button) findViewById(R.id.sendtweet);
  6. button.setOnClickListener(new View.OnClickListener() {
  7. public void onClick(View v) {
  8. Intent intent = new Intent("com.twidroid.SendTweet");
  9.  
  10. intent.putExtra("com.twidroid.extra.MESSAGE",
  11. "This is a test from Twidroid public intent.");
  12.  
  13. try {
  14. startActivityForResult(intent, 1);
  15. } catch (ActivityNotFoundException e) {
  16. /* Handle Exception if Twidroid is not installed */
  17. TextView text = (TextView) findViewById(R.id.message);
  18. text.setText("Twidroid Application not found.");
  19. button.setVisibility(View.GONE);
  20. }
  21. }
  22. });
  23.  
  24. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ralph on December 27, 2008

See here how to send direct messages

Posted By: edouardmercier on September 18, 2009

Is it possible to shorten the provided URL in the text message via this service, please?

Posted By: edouardmercier on November 30, 2009

You now (I do not what version from) need to provide the MIME type, which can be "text/plain", "text/twitter", "application/twitter", "image/jpeg", image/png" according to what you intend to do, and the MIME type is set via a intent.setType().

Posted By: stealthcopter on January 16, 2010

This is good, but as edouardmercier says you have to set the intent type using the following:

intent.setType("application/twitter");

To see this and some other improvements that can be made see this blog post

You need to login to post a comment.