public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn1 = (Button) findViewById(R.id.button1);
Button btn2 = (Button) findViewById(R.id.button2);
Button btn3 = (Button) findViewById(R.id.button3);
Button btn4 = (Button) findViewById(R.id.button4);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String categoryName = "This is share data";
try {
Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
String[] recipients = new String[] { "Enter email" };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Email:- " + categoryName);
emailIntent.setType("message/rfc822");
// emailIntent.setType("text/html");
startActivity(emailIntent);
} catch (Exception e) {
String ss = e.getMessage();
Log.e("The error is :", ss);
e.printStackTrace();
}
}
});
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String title = "This is facebook Data";
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://m.facebook.com/sharer.php?u="
+ "www.facebook.com" + "&t=" + title + "&_rdr"));
startActivity(i);
} catch (Exception e) {
e.printStackTrace();
}
}
});
btn3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String title = "This Twitter";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://twitter.com/intent/tweet?text="
+ title + "&url=" + "https://www.twitter.com"));
startActivity(i);
}
});
btn4.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// for Linkeind
}
});
}
}
检查我的代码是否能够将数据共享到Facebook邮件,而twitter也是我想要分享链接的 我已经创建了button4功能,用于向LinkedIn分享数据,所以请帮助我如何做到这一点,这是我第一次学习者无法做到这一点