Proguard : Shrink, obfuscate, and optimize your app To make your app as small as possible, you should enable shrinking in your release build to remove unused code and resources. When enabling shrinking, you also benefit from obfuscation , which shortens the names of your app’s classes and members, and optimization , which applies more aggressive strategies to further reduce the size of your app. This page describes how R8 performs these compile-time tasks for your project and how you can customize them. When you build you project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler to handle the following compile-time tasks: Code shrinking (or tree-shaking): detects and safely removes unused classes, fields, methods, and attributes from your app and its library dependencies (making it a valuable tool for worki...
Posts
Android allows programmers to place images at all four corners of a TextView. For example, if you are creating a field with a TextView and at same time you want to show that the field is editable, then developers will usually place an edit icon near that field. Android provides us an interesting option called compound drawable for a TextView:
1. Open the Settings or Preferences dialog: On Windows or Linux, select File > Settings from the main menu. On Mac OSX, select Android Studio > Preferences from the main menu. 2. Navigate to Build, Execution, Deployment > Compiler. 3. In the text field next to Command-line Options, enter your command-line options. 4. Click OK to save and exit. The top option is Instant run. Check/uncheck that box.
Enable Offline Work: 1. Click File -> Settings. Search for "gradle" and click in Offline work box. 2. Go to Compiler (in same settings dialog just below Gradle) and add --offline to Command-line Options text box. Improve Gradle Performance Add following two line of code in your gradle.properties file. org.gradle.daemon=true org.gradle.parallel=true Increasing the value of -Xmx and -Xms in studio.vmoptions file -Xms1024m -Xmx4096m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=256m -XX:+UseCompressedOops
Take a screenshot On many Android devices, you can capture a screenshot with a key-combination: Simultaneously press-and-hold Power and Volume-down. You can also capture a screenshot with Android Studio as follows: Run your app on a connected device or emulator. If using a connected device, be sure you have enabled USB debugging . In Android Studio, select View > Tool Windows > Logcat to open Logcat . Select the device and a process from the drop-down at the top of the window. Click Screen Capture on the left side of the window. The screenshot appears in a Screenshot Editor window. Figure 1. Screenshot editor 5.change the image: Recapture : Take a new screenshot. Rotate Left : Rotate the image 90 degrees counter-clockwise. Rotate Right : Rotate the image 90 degrees clockwise. Frame Screenshot : Choose a device to wrap your screenshot with real device ...
Image library Major image loading libraries in android are : 1 . Picasso 2 . Glide 3 . Universal Image Loader 4. Fresco 1 . Picasso ----------------------- GRADLE implementation 'com.squareup.picasso:picasso: 2.71828 ' Picasso.get() .load(url) .placeholder(R.drawable.user_placeholder) .error(R.drawable.user_placeholder_error) .into(imageView); 2 . Glide --------------------- Gradle dependency: repositories { mavenCentral() google() } dependencies { implementation ' com.github.bumptech.glide:glide:4.8.0 ' annotationProcessor ' com.github.bumptech.glide:compiler:4.8.0 ' } Glide. with (getApplication()).load(url) .centerCrop() .crossFade() .error(R.mipmap. ic_launcher ) .diskCacheStrategy(DiskCacheStrategy. ALL ) .into( imageView ); 3 . Universal Image Loader --------------------------------------- Gradle dependency: compile ' com.nostra13.u...
Volley is a networking library for Android that manages network requests. It bundles the most important features you’ll need, such as accessing JSON APIs, loading images and String requests in an easier-to-use package. By using Volley for network operations you avoid the standard way to handle networking, HttpURLConnection . Another reason is asynchronicity. Volley handles asynchronicity by itself, there is no need to create Asynctask manually. Import Volley, add Permissions
<? xml version= "1.0" encoding= "utf-8" ?> < RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: app = "http://schemas.android.com/apk/res-auto" xmlns: tools = "http://schemas.android.com/tools" android :layout_width= "match_parent" android :layout_height= "match_parent" tools :context= "com.arham.csdevbin.downloadimagefrominternet.SharedPreferencesDemo" > < CheckBox android :id= "@+id/checkBox" android :layout_width= "wrap_content" android :layout_height= "wrap_content" android :layout_alignParentLeft= "true" android :layout_alignParentStart= "true" android :layo...
activity_main.xml <? xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: app = "http://schemas.android.com/apk/res-auto" xmlns: tools = "http://schemas.android.com/tools" android :layout_width= "match_parent" android :layout_height= "match_parent" android :orientation= "vertical" tools :context= "com.arham.csdevbin.downloadimagefrominternet.MainActivity" > < ImageView android :id= "@+id/imageView" android :layout_width= "300dp" android :layout_height= "400dp" android :layout_gravity= "center_horizontal" an...