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
Post a Comment