Try to use URLUtil.guessFileName(url, null, null) for example. I think this is the best Android way.
More info here: https://developer.android.com/reference/android/webkit/URLUtil.html#guessFileName(java.lang.String, java.lang.String, java.lang.String)