Im developing an app with the latest android version (4.2.1 API-Level 17) for tablets with multiuser capabilities.

I want to restrict certain features (like the access to the app preferences) to the owner of the tablet (that is the user who can add and remove other user accounts)

is there any way i can find out if the current user is the owner?

i read through the UserManager and UserHandle API docs but couldn't find a function that allows me to check for it.

have i missed something or is there another way to do that?


public boolean isCurrentUserOwner(Context context){    try    {        Method getUserHandle = UserManager.class.getMethod("getUserHandle");        int userHandle = (Integer) getUserHandle.invoke(context.getSystemService(Context.USER_SERVICE));        return userHandle == 0;    }    catch (Exception ex)    {        return false;    }}



更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. AIR Android应用开发实战
  2. Android定时器Timer.schedule
  3. Android未接电话(未接电话个数,以及未接
  4. Android(第一季重制版)
  5. Android(安卓)Studio使用AIDL技术进行SDK
  6. Android(安卓)开发(二)登陆界面
  7. 用GDB远程调试android native程序
  8. Android:Activity生命周期深入详解
  9. Android(安卓)Studio怎样更改JDK和SDK的
  10. Android客户端与服务器端通过DES加密认证