Thursday, April 14, 2016

OnFocusOut Event on EditText Android Studio

We can check if EditText control has focus on or not using the following event.

txtFrom.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            public void onFocusChange (View v, boolean hasFocus) {
                     // Do Code here

I hope it was inforamtive for you and I would like to Thank you for reading

Saturday, April 9, 2016

Send Data Back and forth between Two Activities Android Studio


In this tutorial I will demonstrate how to send data back and forth between two activities.

Consider two Activities

1. Home Activity        (This is the Launcher Activity)
2. Detail Activity

Our goal is to send data from Home Activity to Detail Activity, use that received data, concatenate some extra string in it and than send it back to Home Activity via Button click event

Home Activity Code

private void SendDataToDetailActivity () {
        EditText fn = (EditText) findViewById(;
        Intent obj = new Intent(this, Details.class);
        obj.putExtra("Name", fn.getText().toString());
        startActivityForResult(obj, 100);

Now override the onActivityResult Method
    protected void onActivityResult (int requestCode, int resultCode, Intent data) {
        if (requestCode == 100) {

            if (resultCode == RESULT_OK) {

                Toast.makeText(Home.this, data.getStringExtra("result"), Toast.LENGTH_SHORT).show();

Now in detail Activity Define the method
private void GetDetails() {

        TextView txtF = (TextView) findViewById(;
        String Name = getIntent().getStringExtra("Name");
        Student objS = new Student(Name);
        Name = objS.getName();
        String[] ss = Name.split("!");
Now to send data back to Home Activity use the following Method
public void NavigateToBack (View view) {
        String Name = getIntent().getStringExtra("Name");
        Intent obj = getIntent().putExtra("result", Name + " You just received a Message from Another Activity");
        setResult(RESULT_OK, obj);

I hope that it was informative for you and I would like to Thank you for reading.

Monday, March 21, 2016

Verify MD5 and SHA-1 cryptographic hash values

         Today in this tutorial I'm gonna show you how you can verify MD5 and SHA-1 code of a file which you have downloaded form the Internet.

It is very usefull to verify MD5 and SHA-1 code to make sure that the file you just downloaded is not corrupted and altered by any mean.

So in order to check MD5 and SHA-1 code you will need to download a utility called

File Checksum Integrity Verifier (FCIV)

Download From Here

After downloading Extract it in a folder where your download files are.

Now open up your folder which contain your downloaded file Press shift + right click and select open command window from here.

now type fciv [Your Full File name] without brackets.

Example lets say we have a file called taqi.jpg now to check the code for this file type

fciv taqi.jpg

I hope that it was informative for you and I would like to Thank you for reading.

Saturday, February 20, 2016

Implement Gestures in Android Phone Android Studio

Hello everyone today I will be showing you how to capture touch events in your Android application

For detecting gesture you will need to import few classes in your code so import the following classes

1:  import android.view.MotionEvent;  
2:  import android.view.GestureDetector;  
3:  import;  

You will also need to implement the following Interfaces

1. GestureDetector.OnGestureListener

2. GestureDetector.OnDoubleTapListener

Like this

1:  public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {  
Now we will need to implement all methods for these interfaces so press Alt + Insert this will list all methods available to be implemented Click on OK In you onCreate Method paste the following code

1:  txtans=(TextView) findViewById(;  
2:      gestureDetector = new GestureDetectorCompat(this,this);  

Now for all the implemented method change the return type to true from false
We will also need to implement one last method so again press Alt + Insert and select onTouchEvent

1:    public boolean onTouchEvent(MotionEvent event) {  
2:      this.gestureDetector.onTouchEvent(event);  
3:      return super.onTouchEvent(event);  
4:    }  

I hope that it was informative for you and I would like to Thank you for reading.

Sunday, February 14, 2016

Android Multiple Event Handling Java

In this tutorial I will show you how to handle multiple events in Java for Android Development.

We will use a button and use their onClick and OnLongClick events to change the value of TextView

1:    protected void onCreate(Bundle savedInstanceState) {  
2:      super.onCreate(savedInstanceState);  
3:      setContentView(R.layout.activity_main);  
4:      client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();  
5:      Button btn = (Button) findViewById(;  
6:      btn.setOnClickListener(new Button.OnClickListener(){  
7:        public void onClick(View v){  
8:          btnonClick();  
9:        }  
10:      });  
11:      btn.setOnLongClickListener(new Button.OnLongClickListener(){  
12:        public boolean onLongClick(View c){  
13:          longClick();  
14:          return true;  
15:        }  
16:      });  
17:    }  
18:    public void longClick(){  
19:      TextView txt = (TextView)findViewById( ;  
20:      txt.setText("That was a long click");  
21:    }  
22:  public void btnonClick(){  
23:    TextView txt = (TextView) findViewById(;  
24:    txt.setText("Dont touch me");  
25:  }  

I hope that it was informative for you and I would like to Thank you for reading