bottaw.com
Mama Said There'd
The Gods Are Angry
People are leaving
FTL, LTL, and Long
Amber alert
All Hell Breaks Lo
borkbun.com
Suspicion
Bath salts and recaiacts.com", null);
try {
startActivityForResult(
Intent.createChooser(
"Share text", "Share via"), REQUEST_SHARE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(),
"There are no email clients installed.",
Toast.LENGTH_SHORT).show();
}
}
private void doSend(Uri uri) {
// TODO Auto-generated method stub
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
String subject = data.getStringExtra(EXTRA_SUBJECT);
String text = data.getStringExtra(EXTRA_TEXT);
sendEmail(
"mytestaccount@gmail.com",
subject,
text);
}
}
}
A:
If you are using Facebook SDK, this below code should do the job
private void shareText(String text) {
// Check for success tag
Log.d("share_button", "success!");
try {
Log.d("share_button", "Starting share text on Facebook...");
String name = "Name";
String email = "email@example.com";
String textmsg = "Text message";
ArrayList targetTokens = new ArrayList();
targetTokens.add("your email id/s or URL to check");
// Create the post params, file name, and content type
ArrayList postParams = new ArrayList();
postParams.add(new BasicNameValuePair("tag", "text"));
postParams.add(new BasicNameValuePair("target_tokens", targetTokens));
postParams.add(new BasicNameValuePair("text", text));
// Upload the file
String fileName = "http://images.com/image.jpg";
String path = Environment.getExternalStorageDirectory().getPath();
File dir = new File(path + "/sdcard/");
dir.mkdirs();
File file = new File(dir, fileName);
FileBody filebody = new FileBody(file);
MultipartEntity multipartEntity = new MultipartEntity();
multipartEntity.addPart("photo", filebody);
multipartEntity.addPart("message", new StringBody(textmsg));
postParams.add(new BasicNameValuePair("caption", "Image"));
postParams.add(new BasicNameValuePair("name", name));
postParams.add(new BasicNameValuePair("description", "Photo from your mobile"));
postParams.add(new BasicNameValuePair("caption_attachment", "file"));
postParams.add(new BasicNameValuePair("image", path + fileName));
// Start Facebook Intent
Intent postToFacebook = new Intent(Intent.ACTION_SEND);
postToFacebook.setType("text/plain");
postToFacebook.putExtra(Intent.EXTRA_TEXT,
URLEncoder.encode(text, "UTF-8"));
postToFacebook.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
postToFacebook.putExtra(
"com.facebook.android.Util.USER_ID", "your id");
postToFacebook.putExtra("com.facebook.android.source", "2");
postToFacebook.putExtra(
"com.facebook.android.AsyncFacebookRunner.REQUEST_CODE", "100");
postToFacebook.putExtra("com.facebook.android.RESPONSE_CODE", "200");
startActivityForResult(
Intent.createChooser(postToFacebook, "Send to"),
100);
} catch (Exception e) {
Log.d("share_button", e.toString());
}
}
Share dialog is shown after sending email but Share is not working as expected.
After checking that you don't get error messages from facebook.
A:
try this
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, "This is a text message");
startActivity(Intent.createChooser(share, "Share"));
A:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Share this text using apps from HERE.");
startActivity(Intent.createChooser(intent, "Share"));
use this it will work fine
And share on facebook like this:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, text);
i.putExtra(Intent.EXTRA_SUBJECT, "Your Subject Here");
i.putExtra(Intent.EXTRA_TEXT, "Your Text Here");
i.setType("text/plain");
startActivity(Intent.createChooser(i, "Share using"));
this will work
and
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, text);
i.putExtra(Intent.EXTRA_SUBJECT, "Your Subject Here");
i.putExtra(Intent.EXTRA_STREAM, "link");
startActivity(Intent.createChooser(i, "Send using"));
this won't work