如何从我的应用程序打开谷歌日历应用程序? [英] How to open google calendar app from my app?

查看:176
本文介绍了如何从我的应用程序打开谷歌日历应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的应用程式开启Google日历应用程式。我有以下代码但它崩溃:

I want to open Google calendar app from my app. I have following code but it crashes:

if (Utils.isPackageInstalled(PACKAGENAME,getApplicationContext())) {
    intent = new Intent(Intent.ACTION_VIEW, Uri.parse( "com.android.calendar"));
    startActivity(intent);
}

LogCat:

04-30 09:14:29.156: E/AndroidRuntime(21225): FATAL EXCEPTION: main
04-30 09:14:29.156: E/AndroidRuntime(21225): Process: com.am, PID: 21225
04-30 09:14:29.156: E/AndroidRuntime(21225): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=com.android.calendar }
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Activity.startActivityForResult(Activity.java:3424)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Activity.startActivityForResult(Activity.java:3385)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Activity.startActivity(Activity.java:3627)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.Activity.startActivity(Activity.java:3595)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at com.amexbarcelo.activity.RootActiveTravel$4.onClick(RootActiveTravel.java:147)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.os.Handler.dispatchMessage(Handler.java:102)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.os.Looper.loop(Looper.java:136)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at android.app.ActivityThread.main(ActivityThread.java:5017)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at java.lang.reflect.Method.invokeNative(Native Method)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at java.lang.reflect.Method.invoke(Method.java:515)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-30 09:14:29.156: E/AndroidRuntime(21225):    at dalvik.system.NativeStart.main(Native Method)


推荐答案

不建议在启动时使用第三方应用程序的程序包名称。您必须指定Action和URI,并让系统找到处理请求的最佳应用程序。

Its not advisable to use the package name for 3rd party application in intent for launching. You must specify the Action and URI and let the system find the best app to handle the request.


  1. Android文档使用日历功能

  2. 如何使用日历功能?

  3. 您需要了解Android日历应用程序的意图

  1. Android Docs on using Calendar Intent,
  2. How to use Calendar Intent?,
  3. What You Need to Know About the Intents of Android’s Calendar App

这篇关于如何从我的应用程序打开谷歌日历应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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