Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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

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

Solution 2:

There is NO WAY to change the homepage url of the browser.

com.android.browser opens/creates a preference with MODE_PRIVATE. So the files's attributes are became as -rw-rw---- And also browser app's menifest has no sharedUserId attribute.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.android.browser">

The app doesn't provide the chance to share app's preference file.

Solution 3:

This cannot be accomplished programmatically from within your app.

Edit: I downloaded the application you provided, and it does appear to accomplish what you're looking for. How exactly it was done, I have no clue. I can't find anything online on how to do this. I'm interested to see if anyone has any ideas on how they accomplished this.

Solution 4:

I hava a opinion: Maybe you can read the source code of Browser and find the code like this:

SharedPreferencesprefs= mContext.getSharedPreferences(RECOVERY_PREFERENCES, Context.MODE_PRIVATE);

and get the SharedPreferences of Browser,then find the place to set homepage, change it. Is that possible?

Solution 5:

Im guessing the app developer didnt write it in his code to do that. I think one of the 11 ad sdks he has in his app is causing it.

He has

adserver.adview
adwhirl
amobee.onlinehapi
apperhand
google
inmobi.androidsdk
jumptap.adtag
mdotm.android.ads
millenialmedia.android
mobclix.android.sdk
zestadz.android

as a side note this is ridiculous.

Post a Comment for "How To Change The Default Android Browser's Homepage Within An App?"