Skip to main content

Posts

Schedule Android Background Job Using Firebase JobDispatcher

From Android version 8.0 (Oreo) on wards there are limitations in executing background services and there are some limitations in receiving certain broadcasts. The android team implement all these restrictions to improve app performance and device battery life. If your app target API 26 then you have to consider some other mechanisms to do your background job.  Fortunately there is JobScheduler API that solve the problem regarding the background job limitations in newer versions of android. Google suggests Android App developers to use the JobScheduler API for their background job execution rather than using a background service.  But the problem is that the android framework JobScheduler API is available from android API version 21(Lollipop) and above. If your app support start from Lollipop and above then you can go for the framework JobScheduler API for your background job. If your App support start from android API lower than 21 then you can use the Firebase JobDispat
Recent posts

Android MySQL Database Operations

In this post we are going to learn about how to connect to MySQL Database from your Android Application and perform database operations. Here we create an android app that contain some login Activity through which the user can retrieve information from database and a registration Activity through which the user can add information into the database.  First you need to have the following components installed in your development machine.  1. Database : Here we use the MySQL database. 2. Web Server : Here we use the Apache Web Server. 3. Server side Scripting Language :   Here we use PHP for server side scripting. 4. Android Development environment : You must install android sdk and android studio.   I recommend you to download and install WAMPSERVER. The wamp server installer contains the following components. Apache Server Application MySQL Database PHP/phpMyAdmin First we have to create the database and table in MySQL. You can use the phpMyAdmin for mange yo

Passing the click events back to the dilaog's host in android

In this post i am going to show you how to get the dialog's click events back to the host activity or fragment. By default the click events of a dialog is handled by the DialogFragment. You can transfer the click events back to the host activity or fragment by declaring an interface in the dilalog class. Ads by Google In this example we have a TextView in the activity_main.xml file. We have to change the font color of the TextView using an alert dialog with single choice list. So the user can select a color from the dilalog and we set that particular color as the font color for the TextView. ColorDialog.java 1: public class ColorDialog extends DialogFragment 2: { 3: CharSequence[] sequence = {"RED","GREEN","BLUE"}; 4: String color_selection; 5: @Override 6: public Dialog onCreateDialog(Bundle savedInstanceState) { 7: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 8:

Create Android Options Menu Programatically

In this post we are going to learn about how to show an android menu without using a separate menu layout xml file. You can create a menu in two ways. 1. Create the menu by inflate an xml file located in the menu folder using the MenuInflater object. 2. Add the menu items dynamically (by writing code) to menu using the add() method. Here I demonstrate how to add the menu items dynamically to an options menu. Step 1:  Override the onCreateOptionsMenu in the MainActivity.java file. @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub } Ads by Google Step 2: Add each menu items to the menu using the add() method and the Menu object.             add(arg1, arg2, arg3, arg4);             The add method takes three arguments.             arg1   =  Indicates the group id . You can pass Menu.NONE if there is no group available.             arg2  =   Indicates the item id.              arg 3 = I

Android Swipe Views with Tabs

In this post we are going to learn about how to integrate the android tab view with the fragments using ViewPager and ActionBar class. For displaying the tabs on the top of the screen you need to interact with the android action bar, this is because the tab views is connected with the action bar. Ads by Google In this example application we make three tabs called "java", "php" and ".Net" and there are three seperate fragement view for each of these tabs. First you need to add the ViewPager into the activity_main.xml file. <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> Now create three layout files for the fragments. 1. java_layout.xml <?xml version="1.0" encod

Android Chat Bubble tutorial

In this post we will discus about how to create a simple android chat application graphical user interface and how the data is displayed in it.   Before going to create this application, you need to know about the 9 patch images. A 9 patch image is a normal png image with 1 dp pixels extra wide border.  In a chat application you can notice that the length and width of the chat bubble (image displayed at the background of the chat message) is automatically stretched based on its contents like shown below. Such type of an image is called a 9 patch image. You can save the 9 patch images in the drawable folder of your application with file extension .9.png . Ads by Google You have a lot of on-line tools are available to make 9 patch images and of-course you can use Photoshop to create your own 9 patch image. You can also use the draw9patch tool available with the android sdk. You can find this tool in the tools folder of your android sdk. Watch video How to create 9 patch

Android Expandable ListView

CLICK HERE TO DOWNLOAD THIS PROJECT activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_height="match_parent"     android:layout_width="wrap_content"     android:paddingLeft="16dp"     android:paddingRight="16dp"     android:paddingTop="16dp"     android:paddingBottom="16dp"     > <ExpandableListView     android:id="@+id/exp_list"     android:layout_height="match_parent"    android:layout_width="match_parent"   android:indicatorLeft="?android:attr/expandableListPreferredItemIndicatorLeft"     android:divider="#A4C739"     android:dividerHeight="0.5dp"      ></ExpandableListView>     </RelativeLayout> parent_layout.xml <?xml version="1.0" encoding="utf