Add border at bottom of TextField in iOS

If you want to make your TextField simple like in Android Lollipop. In this code, your TextField will be clean with a single border at bottom and your placeholder/text. Checkout the below image for that.

Screen Shot 2015-12-31 at 7.35.57 PM

Just add this code in your app and you are ready to go.

textField.backgroundColor=[UIColor clearColor];
textField.borderStyle = UITextBorderStyleNone;
[textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0, textField.frame.size.height - 2, textField.frame.size.width, 2.0f);
bottomBorder.backgroundColor = [[UIColor whiteColor]CGColor];

[textField.layer addSublayer:bottomBorder];

Add “more apps from this developer” button to your Android app

It’s a good practice to add a button called “more apps” or “more apps from this developer” in your Android app. It will increase downloads of your other apps to as well as the user can checkout your other apps if interested.

So now here is the code that you should paste in the button click event or any other place you want.

try {
  //replace "Unified+Apps" with your developer name
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Unified+Apps")));
catch (android.content.ActivityNotFoundException anfe) {
  //replace "Unified+Apps" with your developer name
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("")));

Here we use try and catch because very few Android device do not have Play Store app in their device. In that case, it will open your developer page as a website in the browser.

Try it now!

Admob banner ad integration in Andriod Studio

Admob integration becomes very easy with the Android Studio. No need to include .jar file or google play service lib like in Eclipse. Follow the steps to include admob banner to your app.


  1. Make sure you’ve updated the “Extra” part of your android sdk. Because we need here Google Repository. Now add the following line to dependencies area of your app’s gradle file.
    compile ''

    After pasting this line, check the bottom part of the android studio where it will suggest you to change the version of google play service ads. Because it might be possible that there will be new version of google play service ads. Now click on “sync now” at the top of android studio and you are ready to go.

  2. Now open the AndroidManifest.xml file and include following in different part of the file. First add two permission in the <manifest> tag and out side of <application> tag.
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    Now add meta data in your <application> tag.

    android:value="@integer/google_play_services_version" />

    Now add admob activity in application tag same as meta data.

    android:theme="@android:style/Theme.Translucent" />
  3. Then add the below xml code in your xml layout file where you want to display ad. It’s a good practice to surround your ad with relative layout. So that you can easily hide the ad until it’s load without affecting the rest of your layout.

    Make sure that you set the visibility of the ad to “gone” in xml file. Because we will hide the ad until it loads completely or there will be blank white space until the ad loads from server and it looks bad. Do not forget to replace YOUR_AD_UNIT_ID with your actual Ad unit id created from admob dashboard.

  4. And finally add the following code in your respective Activity file and that’s it! The ad should be loaded.
    final AdView mAdView = (AdView) findViewById(;
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.setAdListener(new AdListener() {
      public void onAdLoaded() {

    It will display the ad once it loaded completely.

You can check the detailed explanation of everything in this tutorial as well as other information about integration here on Google Developers site and download sample app from there.

If you have any issues in the above code, please write them below in comment section. Thank you.

Validation in Java/Android

Many time during my Android development, I need to verify email address, username, password or any specific requirements. Most of times it needs when I am building registration form or login form. So I made the function that takes first argument as string on which validation is needed and pattern [Regular Expression] that decides first argument is valid or invalid.

Here I use two main java class

Here Pattern class compile the regular expression and then Matcher class perform match operation against given String using compiled pattern. Here is the function for that.

	public Boolean validate(String text, String regex)	{
		Pattern pattern;	
		Matcher matcher;
		pattern = Pattern.compile(regex);
    	matcher = pattern.matcher(text);
    	if(matcher.matches())	{
    		return true;
    	else	{
    		return false;

Here you can see that the function validate validates the String text against the regex using Pattern and Matcher class. I attached the example of email validation below, but you can use any validation by just providing their regular expression.

Download example of email validation with comments here :

References :