Beginning another movement doesn’t need to be one-way. You can likewise begin another action and get an outcome back. To get an outcome, call startActivityForResult() (instead than startActivity()).
For instance, your application can begin a camera application and get the caught photograph subsequently. On the other hand, you may begin the People application all together for the client to choose a contact and you’ll get the contact subtle elements subsequently.
Obviously, the action that reacts must be intended to give back an outcome. When it does, it sends the outcome as another Intent article. Your movement gets it in the onActivityResult() callback.
Example –
static final int PICK_CONTACT_REQUEST = 1; ... private void pickContact() { Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts")); pickContactIntent.setType(Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); }
Receive the Result
At the point when the client is finished with the ensuing movement and returns, the framework calls your action’s onActivityResult() strategy. This strategy incorporates three contentions:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICK_CONTACT_REQUEST) { if (resultCode == RESULT_OK) { ------------- ------------- } } }
Android Books To Learn Mobile Apps Programming
- Android Programming: The Big Nerd Ranch Guide
- Android Design Patterns: Interaction Design Solutions for Developers
- Android Application Development Cookbook – Second Edition
- Android User Interface Design: Turning Ideas and Sketches into Beautifully Designed Apps (Usability)
- Android Recipes: A Problem-Solution Approach for Android 5.0
- Hello, Android: Introducing Google’s Mobile Development Platform (Pragmatic Programmers)
- Beginning Android Games
Leave a Reply