I have seen several apps and advertising networks like startapp changing the android web browser homepage by code. How is this possible?
I have taken a look at the startapp sdk but i have not managed to find the part where they change the homepage.
I have also taken a look at the BrowserSettings
in com.android.browser.BrowserSettings
In BrowserSettings
, there is a interface called setHomepage(Context, String)
.
public void setHomePage(Context context, String url) {
Editor ed = PreferenceManager.
getDefaultSharedPreferences(context).edit();
ed.putString(PREF_HOMEPAGE, url);
ed.commit();
homeUrl = url;
}
I dont know a lot java/android, so correct me if i am wrong: The setHomepage()
is not declared static so it can not be called from other activities. So i can not use this.
I cant see any Mode applied to the Shared Preferences so it means that it will by default take Private as is Mode and i cant edit the Shared Preferences or ?
Some people have said that it may would be possible to do with contentProvider/Resolver.
Link for BrowserSettings.java
Any help or thoughts would be appreciated:)
I see that you mentioned startapp. I have looked through their decompiled SDK but i cant find anything about the "changing homepage part".
Also i know that they do this but i cant find it in the SDK. Maybe somebody with better understanding for android can take a look at it. I have a android phone with 2.2 without root access and they managed to change the homepage.
With root permissions, you can go to the /data/app/com.android.browser/shared_prefs
you have there the XML file for the shared preferences.
You just need to edit
PREF_HOMEPAGE
xml entry.without root it is impossible, since you will need root permissions to access that directory.
I'm with Diane HackBorn (Google's Android Engineer) on this one: this shouldn't be possible, as it would be a platform security flaw.
If it happens to be possible, would be through some sort of hack (i.e.: an App with root access that can write into the Browser app Settings file directly).