3

I am trying to use the following code to set my page as the browser homepage, but it is not working:

Context browserContext = createPackageContext("com.android.browser", Context.CONTEXT_IGNORE_SECURITY);

SharedPreferences sp = browserContext.getSharedPreferences("com.android.browser_preferences",Context.MODE_PRIVATE);                 
SharedPreferences.Editor edidor = sp.edit();
edidor.putString("homepage", "http://www.mypage.com");
edidor.commit();

I am getting this warning: ///data/data/com.android.browser/shared_prefs/com.android.browser_preferences.xml without permission.

As both application process ids are different, I cannot access the SharedPreferences of Browser application.

So:

  1. How do I achieve this task?
  2. Are there other approaches to try, such as a javascript or web page loading?
  3. Can I open setHomepage dialog of default browser programmatically?
Cœur
  • 37,241
  • 25
  • 195
  • 267
Swapnil
  • 2,409
  • 4
  • 26
  • 48

1 Answers1

-3

Try after adding android.permission.ACCESS_BROWSER this permission in your android manifest file

anil
  • 33
  • 1
  • 3