2

In R.string.share_content, I am having content more or less like

free download from http://www....

Instead of completely URL, I would like to have short URL (lie bit.ly/AbC) as normally use in Twitter sharing? How is it possible for my app to insert short URL if the share is done through twitter?

private void share() {
    final String share_subject = getString(R.string.share_subject);
    final String share_content = getString(R.string.share_content);
    final String share_intent_title = getString(R.string.share_intent_title);

    File file = mainView.getScreenshotFile();
    Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType("image/jpeg"); 
    intent.putExtra(Intent.EXTRA_SUBJECT, share_subject); 
    intent.putExtra(Intent.EXTRA_TEXT, share_content);
    // http://stackoverflow.com/questions/5214764/how-to-share-photo-with-caption-via-android-share-intent-on-facebook
    intent.putExtra(Intent.EXTRA_TITLE, share_content);

    // http://stackoverflow.com/questions/9023116/sharing-an-image-with-google-app-using-intent-action-send-and-intent-extra-stre
    ContentValues values = new ContentValues(2);
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
    Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    //intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 

    startActivity(Intent.createChooser(intent, share_intent_title));
}
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

1 Answers1

1

You could replace your original URL with tiny URL.

First, call tinyurl api using this link: http://tinyurl.com/api-create.php?url= and append youre URL that you want to "shrink".

Second, you use that new link in your application (intent extras). Your new created link with tinyurl is permanent, as long as your original URL in available.