Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default Android browser's homepage within an app?

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

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

Thanks!

like image 768
Robert Bana Avatar asked Jan 21 '26 13:01

Robert Bana


1 Answers

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

It is used in BrowserBookmarksPage like this:

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

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

MORE...

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...

  • 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.
like image 67
Matthieu Avatar answered Jan 23 '26 04:01

Matthieu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!