java - Is it possible to get the phone's currently selected profile? -


the stock cyanogenmod rom has support profiles baked in , although i'm not sure if part of default android functionality, wondering if possible name of selected profile.

i haven't been able find developer documentation on this.

(assuming android sdk doesn't support this, can superuser app implement functionality?)

thanks


trudging through cm source found source code profilemanager. methods public guess don't need go down rabbit-hole of java reflection...but in order use these classes, need cyanogenmod jars build against.

got it. bit of ugly reflection , voila. classes profilemanager , profile

    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();     } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -