Software Development Exam  >  Software Development Videos  >  Android Application Development (Mobile App)  >  Android Application Development Tutorial - 50 - setResult for the Start Activity For Result

Android Application Development Tutorial - 50 - setResult for the Start Activity For Result Video Lecture | Android Application Development (Mobile App) - Software Development

199 videos

Top Courses for Software Development

FAQs on Android Application Development Tutorial - 50 - setResult for the Start Activity For Result Video Lecture - Android Application Development (Mobile App) - Software Development

1. What is the purpose of setResult in Android application development?
Ans. The setResult method is used to set the result that will be returned to the calling activity when the current activity finishes. It is typically used when the current activity is started for result using startActivityForResult.
2. How does startActivityForResult work in Android application development?
Ans. startActivityForResult is used to start a new activity and expect a result back from that activity. The called activity can set a result using setResult, which will be returned to the calling activity when the called activity finishes.
3. Can you provide an example of using setResult and startActivityForResult in Android application development?
Ans. Sure! Here's an example: In the calling activity: ``` Intent intent = new Intent(this, CalledActivity.class); startActivityForResult(intent, REQUEST_CODE); ``` In the called activity: ``` Intent resultIntent = new Intent(); resultIntent.putExtra("key", value); setResult(RESULT_OK, resultIntent); finish(); ``` In the calling activity (onActivityResult method): ``` @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE) { if (resultCode == RESULT_OK) { // Handle the result from the called activity String value = data.getStringExtra("key"); // Do something with the result } } } ```
4. What is the difference between startActivity and startActivityForResult in Android application development?
Ans. The startActivity method is used to start a new activity without expecting any result back. On the other hand, startActivityForResult is used to start a new activity and wait for a result to be returned from that activity.
5. Is it necessary to use startActivityForResult for result handling in Android application development?
Ans. No, it is not necessary to use startActivityForResult for result handling. It depends on the specific requirements of the application. If the calling activity does not need any result from the called activity, then startActivity can be used instead. However, if the calling activity expects a result, startActivityForResult should be used.
Explore Courses for Software Development exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Important questions

,

past year papers

,

Exam

,

Previous Year Questions with Solutions

,

practice quizzes

,

Summary

,

Semester Notes

,

Sample Paper

,

video lectures

,

Android Application Development Tutorial - 50 - setResult for the Start Activity For Result Video Lecture | Android Application Development (Mobile App) - Software Development

,

pdf

,

Android Application Development Tutorial - 50 - setResult for the Start Activity For Result Video Lecture | Android Application Development (Mobile App) - Software Development

,

Viva Questions

,

shortcuts and tricks

,

Objective type Questions

,

Extra Questions

,

MCQs

,

study material

,

ppt

,

Free

,

mock tests for examination

,

Android Application Development Tutorial - 50 - setResult for the Start Activity For Result Video Lecture | Android Application Development (Mobile App) - Software Development

;