How to programmatically take a screenshot on Android?

Here is the code that allowed my screenshot to be stored on an SD card and used later for whatever your needs are: First, you need to add a proper permission to save the file: <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/> And this is the code (running in an Activity): private void takeScreenshot() { Date now = new Date(); … Read more

How to clear gradle cache?

Gradle cache is located at On Windows: %USERPROFILE%\.gradle\caches On Mac / UNIX: ~/.gradle/caches/ You can browse to these directory and manually delete it or run rm -r $HOME/.gradle/caches/ on UNIX system. Run this command will also force to download dependencies. UPDATE Clear the Android build cache of current project NOTE: Android Studio’s File > Invalidate … Read more

More than one file was found with OS independent path ‘META-INF/LICENSE’

You can add this in yourProject/app/build.gradle inside android{}. The exclude function adds the named resource to the list of resources that are not packaged in the APK. android { packagingOptions { exclude ‘META-INF/DEPENDENCIES’ exclude ‘META-INF/LICENSE’ exclude ‘META-INF/LICENSE.txt’ exclude ‘META-INF/license.txt’ exclude ‘META-INF/NOTICE’ exclude ‘META-INF/NOTICE.txt’ exclude ‘META-INF/notice.txt’ exclude ‘META-INF/ASL2.0’ exclude(“META-INF/*.kotlin_module”) } } The exclude function is deprecated … Read more

How to set tint for an image view programmatically in android?

UPDATE: @ADev has newer solution in his answer here, but his solution requires newer support library – 25.4.0 or above. You can change the tint, quite easily in code via: imageView.setColorFilter(Color.argb(255, 255, 255, 255)); // White Tint If you want color tint then imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.MULTIPLY); For Vector Drawable imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.SRC_IN);

How to send emails from my Android application?

The best (and easiest) way is to use an Intent: Intent i = new Intent(Intent.ACTION_SEND); i.setType(“message/rfc822”); i.putExtra(Intent.EXTRA_EMAIL , new String[]{“recipient@example.com”}); i.putExtra(Intent.EXTRA_SUBJECT, “subject of email”); i.putExtra(Intent.EXTRA_TEXT , “body of email”); try { startActivity(Intent.createChooser(i, “Send mail…”)); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(MyActivity.this, “There are no email clients installed.”, Toast.LENGTH_SHORT).show(); } Otherwise you’ll have to write your own … Read more

Can the Android drawable directory contain subdirectories?

No, the resources mechanism doesn’t support subfolders in the drawable directory, so yes – you need to keep that hierarchy flat. The directory layout you showed would result in none of the images being available. From my own experiments it seems that having a subfolder with any items in it, within the res/drawable folder, will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)