Intro:
This project allows you to calculate the direction between two locations and display the route on a Google Map using the Google Directions API.

Github Link:
https://github.com/jd-alexander/Google-Directions-Android

Screenshot:

Sample:
The sample makes use of the Google Places API for Android in order to provide a real life example of how the library can be used.
Directions Sample App


Like writing Android network plumbing code? Didn't think so. Start with Firebase in 3 minutes




In Android, this form validation lib simplify and streamline the code to validate a form. It validates all type of EditText. It is used for all validation like
* Email
* Credit card Exp Year,Month, cvv

* Username
* Required Fields etc


 public class Formvalidation {  
      Context context;  
      EditText Username, Password, PhoneNumber;  
      static String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";  
      public Formvalidation(Context context) {  
           this.context = context;  
      }  
      public static boolean isFirstName(EditText Et_Firstname) {  
           return Et_Firstname.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isLastName(EditText Et_LastName) {  
           return Et_LastName.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isUsername(EditText Et_Username) {  
           return Et_Username.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isEmailValid(EditText Et_Username) {  
           return !Et_Username.getText().toString().matches(emailPattern) ? false : true;  
      }  
      public static boolean isConformPassword(EditText Et_ConformPassword) {  
           return Et_ConformPassword.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isPassword(EditText Et_Password) {  
           return Et_Password.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isPasswordMinLength(EditText Et_Password) {  
           return Et_Password.getText().toString().trim().length()<6 ? false : true;  
      }  
      public static boolean isConformPasswordMatch(EditText et_Password,  
                EditText et_ConformPassword) {  
           // TODO Auto-generated method stub  
           return !et_Password.getText().toString()  
                     .equals(et_ConformPassword.getText().toString()) ? false : true;  
      }  
      public static boolean isPhoneNumber(EditText Et_Phonenumber) {  
           return Et_Phonenumber.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isValidPhonenumber(EditText Et_valid_Phonenumber) {  
           return Et_valid_Phonenumber.getText().toString().length() != 10 ? false  
                     : true;  
      }  
      public static boolean isAddress(EditText Et_Address) {  
           return Et_Address.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isDob(EditText Et_Dob) {  
           return Et_Dob.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isCardNumber(EditText Et_CardNumber) {  
           return Et_CardNumber.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isCardHolder(EditText Et_CardHolder) {  
           return Et_CardHolder.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isAmount(EditText Et_Amount) {  
           return Et_Amount.getText().toString().isEmpty() ? false : true;  
      }  
      public static boolean isExpireMonth(Spinner Expire_Montht) {  
           return Expire_Montht.getSelectedItem().toString().equals("Month") ? false : true;  
      }  
      public static boolean isExpireYear(Spinner Expire_Year) {  
           return Expire_Year.getSelectedItem().toString().equals("Year") ? false : true;  
      }  
      public static boolean isCvvr(EditText Et_Cvvt) {  
           return Et_Cvvt.getText().toString().isEmpty() ? false : true;  
      }  
 }  

Registering with Google Cloud Messaging


  • Goto Google APIs Console page and create a new project. (If you haven’t created already otherwise it will take you to dashboard)




  • After creating project you can see the project id in url. Note down the project id which will be used as SENDER ID in android project. (Example: in #project/encoded-region-847 after semicolon encoded-region-847 is the sender id)








  • Once you are done, click on Credentials and Create new Key in Public API access and Select Browser key. Leave empty and Create key.





    This API key will be used when sending requests to GCM server.







Android Application Architecture:










Android Application Architecture has following components such as
Services, Intent, Resources Externalization, Notification signaling users, Content providers



Dalvik Virtual Machine
It is optimizes the JVM for memory,battery,performance. It optimized for mobile devices.

Activities
An activity represents a single screen with user interface.
 public void MyActivity extends Activity{  
 }  

Service
Service is like an Activity but has no interface. It is component that runs in background for long running process eg: music player
Types:
  • Unbound Services 
    • It runs in the background indefinitely, even if the activity which started this  service ends.
  • Bound Services
    • It runs till lifespan of the activity which started this service. Client-Server interface.
 public void MyService extends Service{  
 }  
 <service android:name=”.MyService”/>  

Intent
Describing specific action. 
Types:
  • Implicit Intent
    • It redirect from Activity in application to external application activity.
    •  Uri uri = Uri.parse(“http://www.google.com”);  
       Intent i = new Intent(Intent.ACTION_VIEW,uri);  
       startActivity(i);  
      
  • Explicit Intent
    • It redirect from Activity to another Activity in application.
    •  Intent i = new Intent(this,SecondActivity.class);  
       startActivity(i);  
      

BroadcastReceiver
It simply respond to broadcast messages from other applications or from the system.
 public class MyReceiver extends BroadcastReceiver{  
 public void onReceive(Context context,Intent intent){}  
 }  

Content Providers
A content provider component supplies data from one application to others on request.


Implementing custom font in whole application is very easy. We can set any custom font to our whole android application just like a theme. This is very simple procedure and easy to implements. 

Needs:

  • Custom font (stored in Asset folder)
  • Commonfont util to apply font for TextView,Button,EditText,CheckBox etc.. in whole application


CommonFont.java


 import android.content.Context;  
 import android.graphics.Typeface;  
 import android.util.Log;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.Button;  
 import android.widget.CheckBox;  
 import android.widget.EditText;  
 import android.widget.RadioButton;  
 import android.widget.TextView;  
 public class CommonFont {  
      public static void setfont(final Context context, final View viewroot, final String fontpath) {  
           try {  
                if(viewroot instanceof ViewGroup) {  
                     ViewGroup viewgroup = (ViewGroup) viewroot;  
                     int childCount = viewgroup.getChildCount();  
                     for (int i = 0; i < childCount; i++){  
                          setfont(context, viewgroup.getChildAt(i),fontpath);  
                     }  
                }else if (viewroot instanceof TextView)  
                     ((TextView) viewroot).setTypeface(Typeface.createFromAsset(context.getAssets(), fontPath));  
                 else if (viewroot instanceof Button)  
                          ((Button) viewroot).setTypeface(Typeface.createFromAsset(context.getAssets(), fontPath));  
                 else if (viewroot instanceof EditText)  
                          ((EditText) viewroot).setTypeface(Typeface.createFromAsset(context.getAssets(), fontPath));  
                 else if (viewroot instanceof CheckBox)  
                          ((CheckBox) viewroot).setTypeface(Typeface.createFromAsset(context.getAssets(), fontPath));  
           } catch (Exception e) {  
                e.printStackTrace();  
           }  
      }  
 }

In Activity:
Just use like below

 CommonFont.setfont(context, findViewById(R.id.container),"font/Roboto.ttf");  

 View view;  
 CommonFont.setfont(context, view,"font/Roboto.ttf");  

In Android we use ARGB, so Transparency take part as below

100% —  FF
95% —    F2
90% —    E6
85% —    D9
80% —    CC
75% —    BF
70% —    B3
65% —    A6
60% —    99
55% —    8C
50% —    80
45% —    73
40% —    66
35% —    59
30% —    4D
25% —    40
20% —    33
15% —    26
10% —    1A
5% —      0D
0% —      00



A- ff (Opacity)
R- 4c (Red)
G- bc (Green)
B- 5f (Blue)