How to delay with a specific time

Hey,

I’m going to show you how to delay a method or a code segment on Android with a piece of code particle. It’s very easy and useable as you need.

 new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                // Magic here
            }
        }, 1000); // Millisecond 1000 = 1 sec



First you need to create a Handler object and use its own method which is “postDelayed” and override the Runnable object’s run method. If you need a specific time to delay like 1000 millisecond (1 second), this method is great to use.
Important Note : After using this postdelayed method, never forget to stop runnable and more importantly, NEVER use it for UI Staff. Otherwise, your UI or your whole app may crash. Thank you Wayne May for this note.

How to extract filename from Uri?

Now, we can extract filename with and without extension :) You will convert your bitmap to uri and get the real path of your file. Now w...