Android的startActivityForResult不返回日历数据 [英] Android startActivityForResult not returning on calendar data

查看:204
本文介绍了Android的startActivityForResult不返回日历数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 的code下面写我的作品

                意向意图=新的意图(Intent.ACTION_EDIT);
                intent.setType(vnd.android.cursor.item /事件);
                intent.putExtra(标题,你好,这我);
                intent.putExtra(说明,有些说明);
                intent.putExtra(BEGINTIME,eventStartInMillis);
                intent.putExtra(endTime的,eventEndInMillis);
                startActivityForResult(意向,1);
 

我的问题是,我不能回来了android日历数据OnActivityResult,我不知道为什么,请帮助我这个问题。

 保护无效onActivityResult(INT申请code,INT结果code,意图数据){

如果(要求code == 1){

     如果(结果code == RESULT_OK){

      字符串结果= data.getStringExtra(标题);

}


而我得到data.getExtras()为null !!!!!
 

解决方案

如果你看一下官方文档: <一href="http://developer.android.com/reference/android/app/Activity.html#setResult%28int,%20android.content.Intent%29"相对=nofollow> http://developer.android.com/reference/android/app/Activity.html#setResult(INT,android.content.Intent) 你会看到在onActivityResult()得到的意图其实是依赖于你所呼叫的活动。更具体地说,它取决于被叫活动是否使用的setResult(整型,android.content.Intent)与额外或不是意图

这是一个快速的互联网搜索似乎你正在使用code是添加在日历中的事件,但这并不neccessary意味着你将得到事件数据从日历应用程序了。 Perhups你要查询日历事后得到它们。

对于联系人应用程序,它明确规定,以便在联系供应商指南,那你可以在onActivityResult联系人数据()如果你使用startActivityForResult。在日历提供指南不存在这样的语句,所以它可能是不支持的。

   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 !!!!!

解决方案

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.

这篇关于Android的startActivityForResult不返回日历数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆