startActivityForResult日历事件ACTION_INSERT不返回到应用程序 [英] startActivityForResult on calendar event action_insert not returning to app

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

问题描述

下面code开始创建新的日历事件日历事件编辑活动。后来,我想它通过调用onActivityResult回到我的应用程序。这没有发生。相反,它返回到日历议程观活动。

The following code starts the calendar event editing activity for creating a new calendar event. Afterwards, I would like it to return to my app via a call to onActivityResult. That is not happening. Instead, it is returning to the calendar agenda view activity.

这里的code表示启动事件编辑器。

Here's the code that launches the event editor.

public void onAddToCalendar (String description)
{
  Intent intent = new Intent (Intent.ACTION_INSERT);
  intent.setData (CalendarContract.Events.CONTENT_URI);
  intent.putExtra (Events.TITLE, description());
  startActivityForResult (intent, ACTIVITY_RESULT_ADD_EVENT);
}

我需要什么做的就是这个,通过onActivityResult回到我的应用程序?我运行的是Android 4.1.2。

What do I need to do to get this to return to my app through onActivityResult? I'm running android 4.1.2.

推荐答案

只是重载父活动下面的方法,如活性A和B

just override the following method in the parent activity such as Activity A and B

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
}

启动活动上使用您的onClick方法

Start Activity on your onClick method using

   startActivityForResult(intentName, 0);

在儿童活动使用/覆盖的onStop()方法

In Child Activity you use/override onStop() method

    @Override
    protected void onStop()
    {
         super.onStop();
     }

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

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