" Bookmark History"之间的区别权限标记

时间:2018-02-21 12:55:58

标签: android user-permissions

以下两个与浏览器书签历史相关的Android权限有什么区别?

<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/> -->
<uses-permission android:name="android.permission.READ_HISTORY_BOOKMARKS" />

我的应用程序仅适用于第一个,并且与第二个崩溃。

SDK版本:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

错误使用第二个权限标记时记录:

E/AndroidRuntime: FATAL EXCEPTION: main
              java.lang.SecurityException: Permission Denial: reading com.android.browser.provider.BrowserProvider2 uri content://browser/bookmarks from pid=5063, uid=10050 requires com.android.browser.permission.READ_HISTORY_BOOKMARKS, or grantUriPermission()
                  at android.os.Parcel.readException(Parcel.java:1431)
                  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
                  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
                  at android.content.ContentProviderProxy.query(ContentProviderNative.java:385)
                  at android.content.ContentResolver.query(ContentResolver.java:414)
                  at android.content.ContentResolver.query(ContentResolver.java:357)
                  at course.labs.permissionslab.BookmarksActivity.loadBookmarks(BookmarksActivity.java:56)
                  at course.labs.permissionslab.BookmarksActivity.access$000(BookmarksActivity.java:14)
                  at course.labs.permissionslab.BookmarksActivity$1.onClick(BookmarksActivity.java:32)
                  at android.view.View.performClick(View.java:4240)
                  at android.view.View$PerformClick.run(View.java:17721)
                  at android.os.Handler.handleCallback(Handler.java:730)
                  at android.os.Handler.dispatchMessage(Handler.java:92)
                  at android.os.Looper.loop(Looper.java:137)
                  at android.app.ActivityThread.main(ActivityThread.java:5103)
                  at java.lang.reflect.Method.invokeNative(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:525)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                  at dalvik.system.NativeStart.main(Native Method)

Android版: 4.3.1

谢谢!

1 个答案:

答案 0 :(得分:0)

此版本删除了对全局书签的支持。现在已删除android.provider.Browser.getAllBookmarks()android.provider.Browser.saveBookmark()方法。同样,删除了READ_HISTORY_BOOKMARKS和WRITE_HISTORY_BOOKMARKS权限。如果您的应用面向Android 6.0(API级别23)或更高版本,请勿访问全局提供商的书签或使用书签权限。相反,您的应用应该在内部存储书签数据。

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-bookmark-browser