Reputation: 472
On my website I want to provide a link to open the (native) calendar app. On iOS this Window.open("calshow:", null, null);
works fine. I cannot find an equivalent URL scheme on Android.
Is there any?
Upvotes: 1
Views: 4428
Reputation: 3952
When a URL is clicked in an Android browser, the system checks to see if the URL path matches any of the Intent Filters that the developers included in AndroidManifest.xml (a file bundled with every app installed on the system). If there is a match between the clicked URL and one of the Intent Filters, the user is prompted to handle the click in the relevant app rather than in the browser. Here is a snippet of an older version of the Google Calendar Android app manifest with the relevant URLs from one of the Intent Filters; any URL that matches these paths and is clicked on will be directed to the Calendar app.
<data android:scheme="http" android:host="www.google.com" android:pathPrefix="/calendar/event" />
<data android:scheme="https" android:host="www.google.com" android:pathPrefix="/calendar/event" />
<data android:scheme="http" android:host="www.google.com" android:pathPattern="/calendar/hosted/.*/event" />
<data android:scheme="https" android:host="www.google.com" android:pathPattern="/calendar/hosted/.*/event" />
Basically, you just need to link to regular Google calendars web app and make sure that the path provided matches what is specified in the Google Calendar app Intent Filter. The user can then choose to handle the URL with the app rather than the browser (there is no way to force a user to open an app in Android from a website that I know of).
For more information about how Intent Filters work on Android, check out this article about Intents from the Android documentation.
Upvotes: 3