-
-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Milestone
Description
For activities like turning on Bluetooth or picking a contact, developers must call startActivityForResult, and handle the result in onActivityResult.
In the following snippet, tapping the screen starts an activity to pick a contact. The system's contact picker appears, a contact can be selected (or the process cancelled), returning to the app. However, the overridden method onActivityResult never seems to be called.
(it also seems that mousePressed() isn't called if there is no draw() function)
Processing 3.3.6
Android Mode 4.0.1
Tested on:
- Motorola Moto G2, Android 6.0.0 (original rom)
- Motorola Moto G2, Android 7.1.2 (custom rom)
- Huawei P Smart, Android 8.0.0 (original rom)
public static final int PICK_CONTACT = 57291;
void mousePressed() {
println("mousePressed()");
pickContact();
}
void pickContact() {
println("pickContact()");
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
intent.setType(Phone.CONTENT_TYPE); //should filter only contacts with phone numbers
super.getActivity().startActivityForResult(intent, PICK_CONTACT);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
println("onActivityResult() for code <" + requestCode + ">");
super.onActivityResult(requestCode, resultCode, data);
}