Cf. exemple (formaté grâce à http://codeformatter.blogspot.fr/) :
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//-- Appel de l'URL Twitter avec un message
String msg="Ceci est un Tweet Automatique :)";
String url = "https://twitter.com/intent/tweet?source=webclient&text="+msg;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
//== Appel mail ==
//-- Action messagerie
Intent mailIntent = new Intent(Intent.ACTION_SEND);
//-- Adresse
//mailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"});
//-- objet
mailIntent.putExtra(Intent.EXTRA_SUBJECT, "Objet du texte");
//-- Corps
mailIntent.putExtra(Intent.EXTRA_TEXT, "Corps du sujet !");
mailIntent.setType("application/mail");
//-- Lancement du client de messagerie
startActivity(mailIntent);
//-- Autre appel de la messagerie
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","abc@gmail.com", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT");
startActivity(Intent.createChooser(emailIntent, "Send email..."));
}
Code source disponible à l’adresse : https://www.box.com/s/6jkxfg7aeyy8k696gghx
Utilisation de twitter4j :
http://stacktips.com/tutorials/android/how-to-integrate-twitter-in-android-application
http://stackoverflow.com/questions/28309053/twitter4j-integration-through-android-studio
Votre commentaire