Showing posts with the label application/x-chess-pgn

Viewing application/x-chess-pgn MIME type

Starting with v3.1, Chess for Android registers itself as a viewer for the application/x-chess-pgn MIME type. This implies that when other Android applications request viewing a game in PGN format, Chess for Android, or any other chess program that supports this type, will open the game.

I am new to this mechanism, but the following two ways of viewing a game seem to work well. To request viewing a game in PGN format that resides in a file (with proper permissions, so that other applications can read it), simply use the following code sequence:

Intent intent = new Intent(Intent.ACTION_VIEW);
File file = ... file in pgn format ....;
intent.setDataAndType(Uri.fromFile(file), "application/x-chess-pgn");

Alternatively, to view a game in PGN format that resides in a String, use the following code sequence (in this case, avoid confusing characters such as ':' in the String format):

Intent intent = new Intent(Intent.ACTION_VIEW);
String data = ".... g…