Skip to content

Instantly share code, notes, and snippets.

@Trumeet
Created March 9, 2019 02:46
Show Gist options
  • Save Trumeet/ca0288a141f7ad4d7bf0b5933c4acac0 to your computer and use it in GitHub Desktop.
Save Trumeet/ca0288a141f7ad4d7bf0b5933c4acac0 to your computer and use it in GitHub Desktop.
Create UserHandle instance without using hidden APIs
object UserHandleUtils {
private fun createUserHandleWithUserID(userId: Int): UserHandle {
val parcel = Parcel.obtain()
// I bet that it won't change a lot
parcel.writeInt(userId)
val userHandle = UserHandle(parcel)
parcel.recycle()
return userHandle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment