views:

38

answers:

0

hello everyone, I require urgent help..

I am creating a sample add contact application using android intents.

heres my code:

Intent addNewContactI;
addNewContactI=new Intent(Contacts.Intents.Insert.ACTION,this.contactsUri);
addNewContactI.putExtra(Contacts.Intents.Insert.NAME, "Sample Name");
startActivityForResult(addNewContactI,RESULT_FIRST_USER);

I am using RESULT_FIRST_USER in a switch case to check user interaction, using following code:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    boolean delete=true;
    switch (requestCode) {
    case SUBACTIVITY_NEW_CONTACT:
        if (resultCode == RESULT_OK) {
            delete=false;
        }
       break;

    }
}

So I think this code will give you idea what I am trying to do. Following are my questions:

  1. Intent to add new contact launches succefully, user is presented with androids bundled add new contact screen and user is able to add Contacts by entering new contact details and pressing Done button. Or user can cancle the addition using revert button. Is there a way so I can change text of Done and Revert Button to OK and Cancle ?
  2. Addition to contact is successfull even when Back button on emulator is pressed, I dont want this to happen, is there a way to solve this issue ? This is what I am trying to achive using onAcitivityResult method. But pressing back button and Done on add contact intent results in RESULT_OK which is making it difficult to monitor exact user interaction. please help!