如何在一个应用程序更改默认的Andr​​oid浏览器的主页? [英] How to change the default Android browser's homepage within an app?

查看:89
本文介绍了如何在一个应用程序更改默认的Andr​​oid浏览器的主页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,是否有可能以编程方式更改Android浏览器的主页网址是什么?如果是这样,我怎么能做到这一点?

Within my app, is it possible to programatically change the Android browser's homepage url? If so, how can I accomplish this?

例如,如果运行了Android 2.3(所有我测试过)这个流行的应用程序,它会改变你的主页来的 http://www.searchmobileonline.com - 的https://market.android.com/details?id=goldenshorestechnologies.brightestflashlight.free

For example, if you run this popular app with Android 2.3 (all that I've tested), it will change your homepage to http://www.searchmobileonline.com -- https://market.android.com/details?id=goldenshorestechnologies.brightestflashlight.free

谢谢!

推荐答案

我没有尝试这个自己,但BrowserSettings有一个公共接口设为首页:

I did not try this myself, but BrowserSettings has a public interface setHomePage:

public void setHomePage(Context context, String url) {
    Editor ed = PreferenceManager.
            getDefaultSharedPreferences(context).edit();
    ed.putString(PREF_HOMEPAGE, url);
    ed.commit();
    homeUrl = url;
}

这是用在BrowserBookmarksPage是这样的:

It is used in BrowserBookmarksPage like this:

BrowserSettings.getInstance().setHomePage(this, [URL]);

但是,这BrowserSettings类是从包只访问。因此,也许访问共享preferences比较容易...?

But that BrowserSettings class is only accessible from that package. So maybe accessing the shared preferences is easier... ?

更多...

不是真的在这里是给一个教训。它可能会做,可能与一些本地的code访问与preferences的浏览器或其他方式像这样的XML文件,但...

Not really here to be giving a lesson. It may be possible to do, maybe with some native code accessing the XML file with the preferences for the Browser or other ways like this, but...

  • 不管你做什么,这将是去绕的安全 地点。您的应用程序不应该是能够改变的网页 浏览器(或它会在文档中)
  • 在即使有可能找到一种方法来做到这一点(通过NDK或发现无证接口),这很可能会停留在某个时候与Android,一些新的版本,可能不是你想要的。工作
  • 在我了解了一些应用程序已经做到这一点,恕我直言,这是很糟糕。并不意味着你的应用程序应该是做同样的阻挠和更多的潜在用户。
  • No matter what you do, this would be going "around" the security in place. Your app should not be able to change the homepage of the Browser (or it would be in the documentation)
  • Even if it is possible to find a way to do it (through NDK or finding undocumented interfaces), it would most likely stop working at some point with some new release of Android, which is probably not what you would want.
  • I understand some app already do it, and IMHO, that's bad. Does not mean that your app should be doing the same and frustrate more potential users.

这篇关于如何在一个应用程序更改默认的Andr​​oid浏览器的主页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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