Get Screen Dimensions Programmatically In Android In Pixels The following source code shows how to get dimensions or screen sizes of the Android device your application is running on: Create an activity class called MainActivity.java and write the following code into onCreate method In dp unit
Android How To Create Rectangle Shape Drawable Using XML
This tutorial show you how to create a rectangle shape using drawable xml resource. It is extremely easy method and consumes less APK size when you compare it with image formats like JPG, PNG, WebP etc that are being bundled within APK. I recommend you to replace all these simple shapes with corresponding shape drawables […]
How To Create Circle Shape Using XML In Android
Android allows us to create shapes using shape drawable. The basic shapes supported in shape drawables are Line, Oval, Rectangle and Ring. This tutorial focuses on how to create circle shape. The drawable created using android shapes are scalable and highly maintainable compared to pre graphics bundled with APK. Here we use Oval. If you […]
How To Disable Back Press In Android
I think you know the architecture of application where activities are being added like stack i.e, LIFO (Last In First Out). Backpress will pop last activity from the memory stack and you are able to view previous activity. In Android we can make changes to this default behavior of an android activity by either overriding […]
How to play mp3 file programmatically
There are some cases where you need to play play mp3 file. Here it is achieving with the help of MediaPlayer Class. Here are the steps Step 1: Create asset folder under java directory Step 2: Save your mp3 file in asset Step 3: write the following code in your activity class
Android | How To Set Default Activity For Android Application?
Very easy to set default activity for Android Application Every app has a landing page we often call it homepage/ default page where we show splash animation or intro page of our app. If our app has more than one activity then we have to know how to set default activity. In Android, you can configure […]
Android Activity LifeCycle Explained
Activity is one of the instances of an android application and we can create activities in android application. Each has it’s own life cycle and callbacks. Lifecycle has been managed by android operating system. An android application existing either in one of the following state of lifecycle. Create Start – UI is visible now Pause – […]