We provide complete mobile and web apps development solutions

Monday, February 4, 2013

Difference between StartActivityForResult, startActivity

Many of them  have confution about startActivity and startActivityForResult() methods.
startActivity() is to start another activity
StartActivityForResult() is to receive a result. The activity has to return a result.
When it returns a result, it sends as another intent object and activity recives result in onActivityResult() and here we can handle.
We need to pass an integer arg to startActivityForResult() method. So that request code will identifies the request.
When you get the result intent, callback provides the same request code to identify the result.

see this example:
  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 1){           
        }       


0 coment�rios:

Post a Comment

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts