我如何收到"共享网址"从浏览器? [英] How do I receive a "Share URL" from browser?

查看:156
本文介绍了我如何收到"共享网址"从浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到这(<一href="http://stackoverflow.com/questions/2886556/how-do-i-handle-the-browsers-share-page-intent-in-android">How我做处理浏览器的&QUOT;分享网页&QUOT;?意图的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);

这篇关于我如何收到&QUOT;共享网址&QUOT;从浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆