Test Script

Friday, July 26, 2013

Custom URL Scheme in Android

Hi guys, I am back with yet another simple but interesting Tutorial for you. Today we will be seeing on how to use a Custom URL scheme in Android.

Why do you even need it, you ask?

Well imagine the possibility if you open your app through a simple link on the Internet. I will be considering two case scenarios here to give you a better idea of the concept.

Scenario 1:

So lets say, for some reason you want to be able to open your app whenever the user clicks on Facebook link.

Here is how to do it :

Inside your activity declaration in the Manifest file, add a Intent Filter with the data tag as below :


So now every time the user clicks on a FB Link your app will be shown as a option to open the link.

Simple and pretty neat huh?

Scenario 2:

So your not happy with just opening FB links & want to open  your app based on some of your links probably placed on your website to provide a tight coupled feeling to the user.

Lets do that now :

This is pretty much similar to the previous approach but here we define our own custom scheme. So again inside the Activity tag in your Manifest file add the following :


Now here we see we have defined our own custom scheme, this could be anything you wish to name. So now on your website just add a anchor tag with the link as the Custom Url scheme.

Click to open my app

Thats it, now when the user clicks on that link through his device , your app will be opened automatically.

There is still a small part left to this , that being how to read the parameters sent through the link. I will be leaving that to a part 2 of this tutorial.

So i guess thats it for this tutorial ! Hope you enjoyed reading it.

As always feel free to drop me a comment below.

Thursday, July 11, 2013

Ellipsize Property of Android

Hi guys , today we will be going over a very short tutorial over a simple TextView property of Android.

I am going to be teaching you the Ellipsize property of a TextView in Android.

This property is useful if you have a long text and have a single line to display it.


My actual long text :
This is some real large text so that we can see the ellipsize effect visible and make a demo out of the same for other users

After applying Ellipsize property :
This is some real large text so that we can see the ellipsize effect visible and make a demo out of ...

Usage :

In list Views if the text is too long then the text gets cut off in middle but this is a graceful way of making it look nice. It enhances the User Experience.

So lets get started :

We will just use a single Activity & a simple layout file for demonstrating this.


package com.example.testellipsize;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

 protected void onCreate(Bundle savedInstanceState) {

 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;


So, this is just a simple plain old Activity nothing at all in the activity. The real magic begins in the XML Layout file






In the above XML all, we did was :

1) Typed some long text , made all the TextViews to show the text in a single Line using 


2) We then set  android:ellipsize property of each textView.

3) We set the Ellipsize property to start,end,middle & marquee which behave as their names suggest.

Thats all for this tutorial , feel free to drop me any comments !


Lets see a screenshot :

As we see the difference is clearly visible, the first TextView shows ... at the start , the second shows at the end similarly 3rd shows in the middle & finally marquee makes the text scroll.