Monday 30 January 2017

Android App for Login Sign Up Using Android Volley and php

In this tutorial we are going code back-end for the Android App we build in other tutorial. For this we will use Android Volley to send request on server. Fortunately, Android studio does most of this part too. We only need to send the request for the login authentication or sign up from our android app.

Which is so simple using android volley and with piece of code, but I made some other changes too in the automatically generated code for our app. Read the comments in the code to understand the code completely. The main changes are:
  • Removed the Async Class as the android volley automatically send the network requests in threads. Android Studio add the async class for the network operations as no network operation can be performed in the main thread.
  • Remove all the relevant code to the async class.
  • Paste the url of your server in string.xml and also change the file name accordingly in the java files. You can make your laptop a server using xampp. Follow the tutorial here for further instructions if you get troubled.
I think that is pretty much all. The rest of code is same. Now move on the tutorial part. The step by step break down for the android app is as follows:
  • Add the uses-permission in Android Manifest file.
    <uses-permission android:name="android.permission.INTERNET"/>
  • Add the dependency for Android Volley in build.gradle (Module: app).
    compile 'com.android.volley:volley:1.0.0'
  • Write the code to send request to server for login or sign up.
  • Write the server side code. For this tutorial I am just sending success from the server for both login.php and signup.php.
    <?php echo "success"; ?>
And that all. You are done with the Android App for Login and Sign Up. You can get the complete android app code with back-end at Github Repository. Or you can get the code below in this post for login and sign up classes.

LoginActivity.java


SignUp.java


In case of error

If you get some error, the first thing you should check is permissions in android androidManifest.xml and build.gradle. If you still get the error feel free to comment below or contact me at farooqahmadkhan003@gmail.com.

Saturday 28 January 2017

Android App for Login Sign Up Form Screen Designing

Every android application has login and registration procedure for authenticating or you can say tracking its users. Today's android tutorial is about designing the login and registration page for android application. Note that this tutorial is just about making the front end designs of the screen. We will cover the back-end coding, database management and sending requests to server in next tutorial. We will be building complete android app with fully functional login and signup with real time database in a step by step. Here is the demo Android App video.



This task is pretty easy now. You already have a template in Android Studio for login activity. And you can make changes according to your need like adding you logo, adding background image, and changing design, which we will learn in this tutorial. Now we should start with tutorial for our android app. Here is the final look of our Login/Signup screens.

sign up activity for android app
Sign Up Activity
login activity for android app
Login Activity

Lets start coding our android app. Step by step instructions are:

  • Create an android studio project.
  • Select the Login Activity template for launching activity of android app.
  • Create new activity named SignUp with Login Activity template.
  • Make necessary changes in the design according to your need.
You can get the complete android app code with back-end at Github Repository. Or you can get the code below in this post for login and sign up screens.

activity_sign_up.xml

activity_login.xml


Next Step

Now the next step is to make these screens functional. And fortunately, Android Studio does most of that part too. We just need to send the request for sign up and login to server and make authentication. For that part follow the next part of tutorial.

Monday 16 January 2017

Android Expandable ListView / ExpandableListView

ExpandableListView is kind of advanced version of Listview. You can expand the list items. It is very useful when you have categories and sub categories of data. Here a tutorial using for ExpandableListView with event listener of parent and child list items.


All you need to do is to follow the simple steps
  • Create main_activity.xml.
  • Create list_group.xml
  • Create list_item.xml.
  • Create the ExpandableListAdapter.java.
  • Create MainActiviy.java.
In ExpandleListAdapter.java, you need to add the @Override some methods of BaseExpandableListAdapter class. important methods are getGroupView and getChildView. In these methods, you need to hook the (in our example) TextView and ImageView of the main list and sublist respectively.

The file main_activity.xml contain the ExpandableListView tag. list_item.xml and list_gruop.xml has the TextViews for list and sublist.

You can get the complete project at Github Repository. Or you can get the code below in this post.

Here is you main_activiy.xml
list_group.xml
list_item.xml
ExpandableListAdapter.java
MainActivity.java

Sunday 15 January 2017

Android tutorial to get last known location using Google Fused Api

androdi-tech-point
This tutorial is about getting last known location using Google Fused Api is similar to getting the current geolocation of the device. But the advantage of using the last known location the if some data about location is already available, it does not request for the current geolocation. Which save the battery consumption and data usage of the device which is always a big problem for the developers.

Here is the demo video of the running app.

In this tutorial, we will do the following tasks:
  • Get the last known location using google fused api.
  • If no data is available, we'll request for the current geolocation updates.
  • Add check for enabling location services of the device.

But first things first. Set up environment for using google play services. For this you need to download the 'Google Play Services' form SDK Manager.

After that add the dependency in the build.gradle(App Module) file:
compile 'com.google.android.gms:play-services:10.0.1'

set up complete for using the getting current location using google fused api.
Add permissions in AndoidManifest,xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />  
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

You can get the complete project at Github Repository. Or you can get the code below in this post.
All done, just add the following code in your MainActivity.java

And the following code in your main_activity.xml