[英]Open my application from Calendar
I'm trying to open my android application from calendar event using CUSTOM_APP_URI. 我正在尝试使用CUSTOM_APP_URI从日历事件中打开我的Android应用程序。
Here is the code i used for inserting the events into calendar 这是我用于将事件插入日历的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Calendar beginCal = Calendar.getInstance();
beginCal.set(2015, 11, 10, 4, 30);
long startTime = beginCal.getTimeInMillis();
Calendar endCal = Calendar.getInstance();
endCal.set(2015, 11, 10, 4, 30);
long endTime = endCal.getTimeInMillis();
ContentValues values = new ContentValues();
values.put(CalendarContract.Events.CALENDAR_ID, 1);
values.put(CalendarContract.Events.TITLE, "Check Demo Calendar4");
values.put(CalendarContract.Events.DTSTART, startTime);
values.put(CalendarContract.Events.DTEND, endTime);
values.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
values.put(CalendarContract.Events.CUSTOM_APP_PACKAGE, getPackageName());
values.put(CalendarContract.Events.CUSTOM_APP_URI, "calendar://1");
getContentResolver().insert(CalendarContract.Events.CONTENT_URI, values);
}
Calendar displaying the ever perfectly but Problem is even after inserting the event doesn't show the URI in my calendar event's detail page. 显示完美但问题的日历即使在插入事件后也没有在我的日历事件的详细信息页面中显示URI。 What is wrong inserting the vent with CUSTOM_APP_URI? 使用CUSTOM_APP_URI插入通风口有什么问题? Any help? 有帮助吗?
Not all calendar apps support the CUSTOM_APP_PACKAGE
field. 并非所有日历应用都支持CUSTOM_APP_PACKAGE
字段。 To my knowledge only the following calendar apps have that feature: 据我所知,只有以下日历应用程序具有该功能:
The last time I checked, neither Samsung's calendar app nor HTC's calendar app supported it. 我最后一次检查时,三星的日历应用程序和HTC的日历应用程序都不支持它。
If anyone is aware of other calendar apps that support the CUSTOM_APP_PACKAGE
, please add them. 如果有人知道其他支持CUSTOM_APP_PACKAGE
日历应用,请添加它们。
Also, make sure your AndroidManifest.xml
contains the correct intent-filter
, see ACTION_HANDLE_CUSTOM_EVENT . 另外,请确保您的AndroidManifest.xml
包含正确的intent-filter
,请参阅ACTION_HANDLE_CUSTOM_EVENT 。
Try this code hope it helps: 试试这段代码希望它有所帮助:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("your_activtiy_package_name");
startActivity(launchIntent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.