Intent use (2)

Source: Internet
Author: User

The meaning of the way of establishing intent is mentioned here, and the function of intent is recorded here, and the value transfer between activity

     startActivityForResult(Intent, int) 。 其中intent是想要做的事情,int 是request_code; intent中的功能执行结束时,需要返回一个
     然后再在该类中重载  onActivityResult(int, int, Intent) 函数来处理返回结果。
Below is the official activity document:
Http://www.android-doc.com/reference/android/app/Activity.html
startActivityForResult(Intent, int)onActivityResult(int, int, Intent)Method.
public class MyActivity extends Activity {
...

static final int pick_contact_request = 0;

protected Boolean onKeyDown (int keycode, keyevent event) {
if (keycode = = Keyevent.keycode_dpad_center) {
When the user Center is presses, let them pick a contact.
Startactivityforresult (
New Intent (Intent.action_pick,
New Uri ("Content://contacts"),
Pick_contact_request);
return true;
}
return false;
}

protected void Onactivityresult (int requestcode, int resultcode,
Intent data) {
if (Requestcode = = pick_contact_request) {
if (ResultCode = = RESULT_OK) {
A contact is picked. Here we'll just display it
to the user.
StartActivity (New Intent (Intent.action_view, data));
}
}
}
}

Intent use (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.