如何为新ACTION_VIEW意向的用户代理 [英] How to set user agent for new ACTION_VIEW intent

查看:139
本文介绍了如何为新ACTION_VIEW意向的用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,我推出一个新的意图使用以下code URL(浏览器):

 意图myIntent =新意图(Intent.ACTION_VIEW,Uri.parse(URL));
尝试{
    context.startActivity(myIntent);
}赶上(ActivityNotFoundException E){
    Log.e(TAG,不能启动浏览器,电子);
}

有没有办法tolet新的活动来发送用户代理

谢谢
-Z


解决方案

  1. 一个人不能以编程方式设置(从应用程序内)用户的浏览器显示自定义用户代理字符串。但是,用户可以通过摆弄一些手工做到这一点,但后来它被设置全系统。


  2. 如果您需要发送自定义用户代理,可以通过的的WebView 。然后,你可以设置自定义的用户代理


In my application I am launching a new Intent with url (browser) using the following code:

Intent myIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));                
try {
    context.startActivity(myIntent);
} catch (ActivityNotFoundException e) {
    Log.e(TAG, "cannot initiate Browser", e);
}

Is there a way tolet the new activity to send user agent

thanks -Z

解决方案

  1. One can not programmatically set (from within an app) user's browser to display a custom user-agent string. However, users can do this by hand via some fiddling, but then this is set system wide.

  2. If you need to send custom user-agent, you can embedded browser into your app via WebView. Then you can set custom user-agent.

这篇关于如何为新ACTION_VIEW意向的用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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