Java 有没有可能拿到电话';您当前选择的配置文件是什么?

Java 有没有可能拿到电话';您当前选择的配置文件是什么?,java,android,cyanogenmod,Java,Android,Cyanogenmod,库存Cyanogenmod ROM支持烘焙的配置文件,虽然我不确定这是否是默认Android功能的一部分,但我想知道是否有可能获得当前选定配置文件的名称 我还没有找到任何关于这个的开发者文档 (假设Android SDK不支持此功能,超级用户应用程序能否实现此功能?) 谢谢 艰难地通过一些CM源代码,我找到了。这些方法是公开的,所以我想我不需要深入Java反射的兔子洞……但是为了使用这些类,我需要一些Cyanogenmod jar来构建它。明白了。一点丑陋的反映,瞧。课程是和 objecto=

库存Cyanogenmod ROM支持烘焙的配置文件,虽然我不确定这是否是默认Android功能的一部分,但我想知道是否有可能获得当前选定配置文件的名称

我还没有找到任何关于这个的开发者文档

(假设Android SDK不支持此功能,超级用户应用程序能否实现此功能?)

谢谢



艰难地通过一些CM源代码,我找到了。这些方法是公开的,所以我想我不需要深入Java反射的兔子洞……但是为了使用这些类,我需要一些Cyanogenmod jar来构建它。

明白了。一点丑陋的反映,瞧。课程是和

objecto=getSystemService(“profile”);
试一试{
Class ProfileManager=Class.forName(“android.app.ProfileManager”);
Class Profile=Class.forName(“android.app.Profile”);
试一试{
方法getActiveProfile=ProfileManager.getDeclaredMethod(“getActiveProfile”,null);
方法getName=Profile.getDeclaredMethod(“getName”,null);
试一试{
String strProfile=(String)getName.invoke(getActiveProfile.invoke(o));
System.out.println(“当前配置文件为:“+strProfile”);
}捕获(非法访问例外e){
e、 printStackTrace();
}捕获(调用TargetException e){
e、 printStackTrace();
}
}捕获(无此方法例外){
e、 printStackTrace();
}           
}catch(classnotfounde异常){
e、 printStackTrace();
}
    Object o = getSystemService("profile");
    try {

        Class<?> ProfileManager = Class.forName("android.app.ProfileManager");
        Class<?> Profile = Class.forName("android.app.Profile");
        try {

            Method getActiveProfile = ProfileManager.getDeclaredMethod("getActiveProfile", null);
            Method getName = Profile.getDeclaredMethod("getName", null);

            try {

                String strProfile = (String) getName.invoke(getActiveProfile.invoke(o));
                System.out.println("Current profile is: " + strProfile);

            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }

        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }           

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }