I try to use ShareActionProvider. It's work but i want put a different text when the user click on Twitter.
How can i fix it?
This my code, the object News contents a title and a url
When he clicks on Twitter :
@account_name myText
And for other
myText
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.detail_news, menu);
MenuItem item = menu.findItem(R.id.action_share);
shareActionProvider = (ShareActionProvider) item.getActionProvider();
shareActionProvider
.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
shareActionProvider.setShareIntent(createShareIntent());
return true;
}
private Intent createShareIntent() {
// Here, is Twitter, add "@Televesdre" in the message
News news = detailAdapter.getCurrentItem(viewPager.getCurrentItem());
String message = news.getTitle() + "\n\n Article: " + news.getUrl();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
return shareIntent;
}
I search how to do before coding because i haven't no idea how to do