当前位置: 代码迷 >> HTML/CSS >> 引见一下android的各种权限。 代码如下: Html代码 <manifestxmlns:androidmanifestxmlns:an
  详细解决方案

引见一下android的各种权限。 代码如下: Html代码 <manifestxmlns:androidmanifestxmlns:an

热度:444   发布时间:2012-08-02 11:35:25.0
介绍一下android的各种权限。 代码如下: Html代码 <manifestxmlns:androidmanifestxmlns:an

?

介绍一下android的各种权限。

代码如下:

Html代码
  1. < manifestxmlns:android manifestxmlns:android = "http://schemas.android.com/apk/res/android" ??
  2. ??????package = "net.sunniwell.launcher" ??
  3. ??????android android:versionCode ="1"android :versionName = "1.0.1" > ??


关于自定义权限,这是很好的例子,其他apk程序要想使用Launcher的功能必须添加这些权限,而这些权限都是在这里声明的。


这个是安装快捷方式的权限定义:

Html代码
  1. < permission ??
  2. ????????android:name = "com.android.launcher.permission.INSTALL_SHORTCUT" ??
  3. ????????android:permissionGroup = "android.permission-group.SYSTEM_TOOLS" ??
  4. ????????android:protectionLevel = "normal" ??
  5. ????????android:label = "@string/permlab_install_shortcut" ??
  6. ????????android:description = "@string/permdesc_install_shortcut" /> ??




这个是卸载快捷方式的权限定义:

Html代码
  1. < permission ??
  2. ????????android:name = "com.android.launcher.permission.UNINSTALL_SHORTCUT" ??
  3. ????????android:permissionGroup = "android.permission-group.SYSTEM_TOOLS" ??
  4. ????????android:protectionLevel = "normal" ??
  5. ????????android:label = "@string/permlab_uninstall_shortcut" ??
  6. ????????android:description = "@string/permdesc_uninstall_shortcut" /> ??



这个是读取launcher.db内容的权限定义:

Html代码
  1. < permission ??
  2. ????????android:name = "net.sunniwell.launcher.permission.READ_SETTINGS" ??
  3. ????????android:permissionGroup = "android.permission-group.SYSTEM_TOOLS" ??
  4. ????????android:protectionLevel = "normal" ??
  5. ????????android:label = "@string/permlab_read_settings" ??
  6. ????????android:description = "@string/permdesc_read_settings" /> ??



这个是修改和删除launcher.db内容的权限定义:

Html代码
  1. < permission ??
  2. ????????android:name = "net.sunniwell.launcher.permission.WRITE_SETTINGS" ??
  3. ????????android:permissionGroup = "android.permission-group.SYSTEM_TOOLS" ??
  4. ????????android:protectionLevel = "normal" ??
  5. ????????android:label = "@string/permlab_write_settings" ??
  6. ????????android:description = "@string/permdesc_write_settings" /> ??
  7. ???


这些是Launcher的权限声明,通过这些就能看出launcher的大概功能了:

打电话权限:

?

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.CALL_PHONE" /> ??


使用状态栏权限:

?

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.EXPAND_STATUS_BAR" /> ??


获取当前或最近运行的任务的信息的权限:

?

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.GET_TASKS" /> ??


读取通信录权限:

?

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.READ_CONTACTS" /> ??


设置壁纸权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.SET_WALLPAPER" /> ??


允许程序设置壁纸hits的权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.SET_WALLPAPER_HINTS" /> ??


使用震动功能权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.VIBRATE" /> ??


修改删除launcher.db内容权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.WRITE_SETTINGS" /> ??


绑定widget权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.BIND_APPWIDGET" /> ??


读取launcher.db内容权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "net.sunniwell.launcher.permission.READ_SETTINGS" /> ??


修改删除launcher.db内容权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "net.sunniwell.launcher.permission.WRITE_SETTINGS" /> ??


读写外部存储设备权限:

Html代码
  1. < uses-permissionandroid:name uses-permissionandroid:name = "android.permission.WRITE_EXTERNAL_STORAGE" > </ uses-permission > ??

?

Html代码
  1. < application ??
  2. ????????android:name = "LauncherApplication" ??
  3. ??????activity应该运行的进程的名字:??
  4. android:process = "android.process.acore" ??
  5. ????????android:label = "@string/application_name" ??
  6. ????????android:icon = "@drawable/swicon" > ??
  7. ??
  8. < activity ??
  9. ????????????android:name = "Launcher" ??
  10. ???????????是否??
  11. android:launchMode = "singleTask" ??
  12. ????????????android:clearTaskOnLaunch = "true" ??
  13. ????????????这个activity是否在被杀死或者重启后能恢复原来的状态:??
  14. android:stateNotNeeded = "true" ??
  15. ????????????android:theme = "@style/Theme" ??
  16. ????????????android:screenOrientation = "landscape" ??
  17. ????????????android:windowSoftInputMode = "stateUnspecified|adjustPan" > ??
  18. ??
  19. < intent-filter > ??
  20. ??
  21. < actionandroid:name actionandroid:name = "android.intent.action.MAIN" /> ??
  22. ??
  23. < categoryandroid:name categoryandroid:name = "android.intent.category.LAUNCHER" /> ??


桌面应用的标记:

Html代码
  1. < categoryandroid:name categoryandroid:name = "android.intent.category.HOME" /> ??
  2. ??
  3. < categoryandroid:name categoryandroid:name = "android.intent.category.DEFAULT" /> ??



自动化测试工具Monkey的标记,待研究…

Html代码
  1. < pre ? class = "html" ? name = "code" > < categoryandroid:name categoryandroid:name = "android.intent.category.MONKEY" /> ??
  2. ??
  3. </ intent-filter > ??
  4. ??
  5. </ activity > </ pre > ??


选择壁纸的activity:

<activity

android:name="WallpaperChooser"

android:label="@string/pick_wallpaper"

android:icon="@drawable/ic_launcher_gallery" >


设置壁纸的intent-filter:

?

Html代码
  1. < intent-filter > ??
  2. ??
  3. < actionandroid:name actionandroid:name = "android.intent.action.SET_WALLPAPER" /> ??
  4. ??
  5. < categoryandroid:name categoryandroid:name = "android.intent.category.DEFAULT" /> ??
  6. ??
  7. </ intent-filter > ??


搜索的activity:

Html代码
  1. </ activity > ??
  2. ??
  3. <!--?Enable?system-default?search?mode?for?any?activity?in?Home?--> ??
  4. ??
  5. < meta-data ??
  6. ????????????android:name = "android.app.default_searchable" ??
  7. ????????????android:value = "*" /> ??
  8. ???


安装快捷方式的广播接收器:

?

Html代码
  1. <!--?Intent?received?used?to?install?shortcuts?from?other?applications--> ??
  2. ??
  3. ??
  4. < receiver ??
  5. ????????????android:name = ".InstallShortcutReceiver" ??
  6. ????????????android:permission = "com.android.launcher.permission.INSTALL_SHORTCUT" > ??
  7. ??
  8. < intent-filter > ??
  9. ??
  10. < actionandroid:name actionandroid:name = "com.android.launcher.action.INSTALL_SHORTCUT" /> ??
  11. ??
  12. </ intent-filter > ??
  13. ??
  14. </ receiver > ??
  15. ???
  16. ??
  17. <!--?Intent?received?used?to?uninstall?shortcuts?from?other?applications--> ??


卸载快捷方式的广播接收器:

?

Html代码
  1. < receiver ??
  2. ????????????android:name = ".UninstallShortcutReceiver" ??
  3. ????????????android:permission = "com.android.launcher.permission.UNINSTALL_SHORTCUT" > ??
  4. ??
  5. < intent-filter > ??
  6. ??
  7. < actionandroid:name actionandroid:name = "com.android.launcher.action.UNINSTALL_SHORTCUT" /> ??
  8. ??
  9. </ intent-filter > ??
  10. ??
  11. </ receiver > ??


声明ContentProvider,用于对launcher.db操作:

Html代码
  1. <!--?The?settings?provider?contains?Home's?data,?like?the?workspacefavorites?--> ??
  2. ??
  3. < provider ??
  4. ????????????android:name = "SWLauncherProvider" ??
  5. ????????????android:authorities = "net.sunniwell.launcher.settings" ??
  6. ????????????android:writePermission = "net.sunniwell.launcher.permission.WRITE_SETTINGS" ??
  7. ????????????android:readPermission = "net.sunniwell.launcher.permission.READ_SETTINGS" /> ??
  8. ???
  9. ??
  10. </ application > ??
  11. ??
  12. < uses-sdkandroid:minSdkVersion uses-sdkandroid:minSdkVersion = "4" /> ??
  13. ???
  14. </ manifest > ??


说明:
1.
<manifest标签头部还应声明:
android:sharedUserId="android.uid.shared",作用是获得系统权限,但是这样的程序属性只能在build整个系统时放进去(就是系统软件)才起作用,手动安装是没有权限的。

  相关解决方案