Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android startActivityForResult not returning on calendar data

   The code Written below works for me

                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setType("vnd.android.cursor.item/event");
                intent.putExtra("title", "Hi this me");
                intent.putExtra("description", "Some description");
                intent.putExtra("beginTime", eventStartInMillis);
                intent.putExtra("endTime", eventEndInMillis);
                startActivityForResult(intent, 1);

my question is that i can't back the android calendar data in OnActivityResult, i don't know why please help me for this issue.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (requestCode == 1) {

     if(resultCode == RESULT_OK){

      String result=data.getStringExtra("title");

}


And i am getting data.getExtras() is null !!!!!
like image 657
miten joshi Avatar asked Dec 06 '12 06:12

miten joshi


2 Answers

It s Because Result code always Return 0 In android calendar Activity result of Calendar implicit intent try using RESULT_CANCEL in onActivity result

public void onActivityResult(int reqCode, int resultCode, Intent data) {

super.onActivityResult(reqCode, resultCode, data);

switch (reqCode) {

if (resultCode == Activity.RESULT_CANCEL)

And You Have to just Check out Next Event ID it will working Hope it will Help to you..

Govind

like image 57
Concept Infoway Avatar answered Sep 19 '22 04:09

Concept Infoway


If you look at the official documentation: http://developer.android.com/reference/android/app/Activity.html#setResult(int, android.content.Intent) you will see that the Intent you get in onActivityResult() is actually dependent on the Activity you are calling. More specifically it depends on whether the called Activity uses setResult(int, android.content.Intent) with an Intent with extras or not.

From a quick internet search it seems that the code you are using is for adding an event in the Calendar, but that does not neccessary mean that you will get the event data back from the Calendar app. Perhups you have to query the Calendar afterwards to get them.

As for the Contacts app, it specifically states so in the Contacts Provider Guide, that you can get the contact data in onActivityResult() if you use startActivityForResult. In the Calendar Provider Guide there is no such statement, so it is probably not supported.

like image 35
Paris Avatar answered Sep 20 '22 04:09

Paris