Receiving and analyzing iCal data via HTTP on Android

I am making an application that asks the user for the user ID, adds the user ID to the static HTTP link to get a user daily schedule file with the extension .ical (calendar).

I need to read data from a file, format in a new user interface and present some useful data on an Android device.

My request is: can I access the HTTP static link backstage? And when I use the same link in the desktop browser, she asks the user to save the file - how can I do this on my mobile phone? Do I need to read the data and save it somewhere, or can I save the .ical file and read it?

+4
source share
1 answer

Android devices, as a rule, cannot process files in the iCalendar (.ics) format - there is no way to simply "open" such a file and display information. You will need to write some code (or use a library such as iCal4j ) to analyze the information in the calendar file.

Based on your question and comments, you need to break it down into several parts:

  • Get user id entered in user interface
    • String userId = ((EditText) findById(R.id.user_id)).getText.toString();
  • Create a unique user url
    • static final String CALENDAR_BASE = "http://example.com/cal/";
      String escapedUserId = URLEncoder.encode(userId, "UTF-8");
      String url = CALENDAR_BASE + escapedUserId +"/events.ics";
  • Get calendar file via HTTP
  • Save file locally
  • Display calendar data to user
    • Read the file from the disk that you saved directly from the Internet.
    • Analyze data with iCal4j and display in any user interface format you like

You can look for stack overflows or ask a more specific question regarding any of the individual parts if you are unsure or need more details. :)

+4
source

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


All Articles