How to open a file with a custom extension created by an application in another solution with the same application?

I have an application that saves database files with the extension ".swt" in a specific folder. I was able to share this file using the intent from one device to another, but the device that received the file could not open it through the same application.

Here is my AndroidManifest with intent filter

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data
  android:scheme="file"
  android:mimeType="*/*"
  android:pathPattern=".*\\.swt" 
  android:host="*" />
</intent-filter>

Here is my file sharing code

ArrayList<Uri>uris = new ArrayList<>();
uris.add(Uri.fromFile(file1));
uris.add(Uri.fromFile(file2));
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
shareIntent.setType("*/*");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,"Share Files Using"))

After some time searching, I found out about the onNewIntent method. But it also does not work.

so how can I make my application to access this file with the extension ".swt"?

+4
source share

No one has answered this question yet.

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


All Articles