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
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.
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...
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.
I authored the app called My Home Page (https://play.google.com/store/apps/details?id=com.aac.myhomepage) where I needed to accomplish this exact task. I looked everywhere possible and couldn't find a method of doing this so I ended up using two workarounds which really aren't great options in my opinion.
1) I offer a root option for those who have rooted devices where I simply access the SharedPreferences XML file of the browser and, using regular expressions, swap out the value of the home page with the one needed.
2) Copy the URL to the clipboard and tell the user how to accomplish changing the default home page.
Note that I did not use root access without the user's permission nor did I change the home page without the user's permission. This is the purpose of the app and the home page isn't changed without the user explicitly doing so.
I recently noticed that the ad SDKs were doing this but something tells me that they aren't doing it in a proper manner and I don't have any interest i
I hava a opinion: Maybe you can read the source code of Browser and find the code like this:
SharedPreferences prefs = 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?
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.