I read this ( How do I handle the browser's "share page" intent in android? ) which I can get the Share link to detect my app, now how do I get Activity to receive the URL?
Found Answer:
Intent intent = getIntent();
if (savedInstanceState == null && intent != null) {
Log.d(TAG, "intent != null");
if (intent.getAction().equals(Intent.ACTION_SEND)) {
Log.d(TAG, "intent.getAction().equals(Intent.ACTION_SEND)");
String message = intent.getStringExtra(Intent.EXTRA_TEXT);
messageText.setText(message);
receiverText.requestFocus();
}
}
When your application receives the "Share page" from the browser, you could also get the title of the webpage:
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
Once you have created an intent filter, your activity should pop up in the list of activities listening to the share link. Then use this in your activity:
String url = getIntent().getStringExtra(Intent.EXTRA_TEXT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With