我如何收到"共享网址"从浏览器?浏览器、网址、QUOT

2023-09-06 03:16:18 作者:大飄雪

我读到这(How我做处理浏览器的"分享网页"?意图的Andr​​oid ),我可以得到分享链接检测我的应用程序,现在我怎么活动收到的网址

找到答案:

 意向意图= getIntent();
如果(savedInstanceState == NULL和放大器;&安培;!意图= NULL){
    Log.d(TAG,意图=空!);

    如果(intent.getAction()。等于(Intent.ACTION_SEND)){
        Log.d(TAG。intent.getAction()等于(Intent.ACTION_SEND));
        字符串消息= intent.getStringExtra(Intent.EXTRA_TEXT);
        messageText.setText(消息);
        receiverText.requestFocus();
    }
}
 

解决方案

在您的应用程序收到来自浏览器的分享网页,你也可以得到网页的标题:

 字符串主题= intent.getStringExtra(Intent.EXTRA_SUBJECT);
 
谷歌浏览器打不开网页无法上网怎么办

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);