Created
June 19, 2018 00:34
-
-
Save slavkoder/ff484b5f84fdb85df25a03e9dcb31234 to your computer and use it in GitHub Desktop.
Add handling for touch outside billing window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
// ... | |
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) | |
window.addFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH) | |
} | |
override fun onBackPressed() { | |
broadcastUserCanceled() | |
super.onBackPressed() | |
} | |
override fun onTouchEvent(event: MotionEvent?): Boolean { | |
if (event?.action == MotionEvent.ACTION_OUTSIDE) { | |
broadcastUserCanceled() | |
} | |
return super.onTouchEvent(event) | |
} | |
private fun broadcastUserCanceled() { | |
broadcastResult(BillingResponse.USER_CANCELED, Bundle()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment