Skip to content

Instantly share code, notes, and snippets.

View anilkumar416's full-sized avatar
🎯
Focusing

Anil Kumar anilkumar416

🎯
Focusing
  • Bengaluru
View GitHub Profile
//file download after permission check
private void fileDownload(String url, String fileName, String fileExtension) {
fileName = fileName + "." + fileExtension;
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
url = url.replace(" ","%20");
System.out.println("URL=> "+url);
DownloadManager downloadManager = (DownloadManager) ((Activity) baseActivity).getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
// Hide the keyboard.
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
// Show the keyboard.
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(editText, 0)
How to use vector images in android studio ?
1. In build.gradle (Module:app)
Inside the defaultConfig
add --> vectorDrawables.useSupportLibrary(true)
2.Add this field in the xml file
xmlns:app="http://schemas.android.com/apk/res-auto"