Export file from android application to Google Calendar application

I searched this topic and found these two sites:

Get uri contents from file path in android

http://developer.android.com/training/basics/intents/sending.html

What I want to do is export the file from the Android application and import the calendar into the Google calendar application. Therefore, if I press the button, my application should send the intention, and the Android App Chooser should appear. Then I want to be able to select a Google calendar and have a calendar to import the file.

This is my code:

Uri uri = Uri.fromFile(new File(fileName)); //Uri uri = Uri.parse(fileName); Intent calendarIntent = new Intent(Intent.ACTION_VIEW, uri); final Intent chooser = Intent.createChooser(calendarIntent, "choose"); ... startActivity(chooser); 

I can open the file with fileName, so this should not be a problem (fileName just contains something like "file.ics"). If I run this code, the Android app developer says that there is no app capable of handling this action. I use the Google API level 7 as a library in Eclipse and I am deploying a Galaxy Nexus device with Android 4.04 for testing. I cannot understand what I am doing wrong. Any suggestions? Thanks in advance for your help!

EDIT:

The following code displays a list of applications to choose from:

 Uri uri = Uri.parse(fileName); Intent calendarIntent = new Intent(Intent.ACTION_SEND, uri); calendarIntent.setType("text/calendar"); final Intent chooser = Intent.createChooser(calendarIntent, "choose"); 

But the calendar is not on this list. So I downloaded the file to my phone and tried to open it. Even then, only text editors appear, but not calendar applications. Therefore, it seems to me that it is impossible to import files into the Google Calendar application. I would be happy if I were mistaken ...

+6
source share

Source: https://habr.com/ru/post/918008/


All Articles