Android以编程方式更改默认浏览器的主页
我正在尝试使用以下代码将我的页面设置为浏览器主页,但它不起作用:Android以编程方式更改默认浏览器的主页,android,android-intent,sharedpreferences,android-browser,Android,Android Intent,Sharedpreferences,Android Browser,我正在尝试使用以下代码将我的页面设置为浏览器主页,但它不起作用: Context browserContext = createPackageContext("com.android.browser", Context.CONTEXT_IGNORE_SECURITY); SharedPreferences sp = browserContext.getSharedPreferences("com.android.browser_preferences",Context.MODE_PRIVATE
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();
我收到这样的警告:
///data/data/com.android.browser/shared\u prefs/com.android.browser\u preferences.xml未经许可
由于两个应用程序进程ID不同,我无法访问浏览器应用程序的SharedReferences
因此:
setHomepage
对话框在您的android清单文件中添加android.permission.ACCESS\u浏览器此权限后重试是否已执行此操作?我需要的正是samenot工作模式,因为共享偏好是MODE_PRIVATE