I would like to have link from the share intent. When I receive a link via chrome its properly formatted, but sometimes other apps add text too.
Example:
Chrome: "www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play"
Twitter: "Guys check out this link it's so cool https://www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play"
So in case of twitter I would like to get rid of all the context and have only the link remaining,ie, www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play
Note: Link may be of any format https://.. (or) www. .. (or) recode.net/... (without the www at the beginning).
Any regex to sort this out?
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareintent);
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null)
{
if ("text/plain".equals(type))
{
// Handle text being sent
handleSendText(intent);
}
}
}
void handleSendText(Intent intent)
{
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null)
{
// Update UI to reflect text being shared
TextView tvShare = (TextView) findViewById(R.id.tvShare);
tvShare.setText(sharedText);
}
}