I'm trying to open my android application from calendar event using CUSTOM_APP_URI.
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. What is wrong inserting the vent with CUSTOM_APP_URI? Any help?
Not all calendar apps support the CUSTOM_APP_PACKAGE
field. 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.
If anyone is aware of other calendar apps that support the CUSTOM_APP_PACKAGE
, please add them.
Also, make sure your AndroidManifest.xml
contains the correct intent-filter
, see ACTION_HANDLE_CUSTOM_EVENT .
Try this code hope it helps:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("your_activtiy_package_name");
startActivity(launchIntent);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.