I am trying to send a text file through Intent to the VC, which I had previously created and saved to the internal storage. However, he writes that he does not support this type of file? The file has the extension .txt

File file = new File(ActivitySettings.this.getFilesDir(), fileName); // создаём новое намерение Intent intent = new Intent(Intent.ACTION_SEND); // устанавливаем флаг для того, чтобы дать внешнему // приложению пользоваться нашим FileProvider intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // генерируем URI, я определил полномочие как ID приложения в манифесте, // последний параметр это файл, который я хочу открыть Uri uri = FileProvider.getUriForFile(ActivitySettings.this, BuildConfig.APPLICATION_ID, file); intent.setData(uri); // подтвердите, что устройство может открыть этот файл! PackageManager pm = getPackageManager(); if (intent.resolveActivity(pm) != null) { startActivity(intent); } 
  • VK does not support uploading txt files - Flippy
  • @Flippy, which text format does it support? - RodGers 1:02 pm
  • Try attaching a uri like this: intent.putExtra(Intent.EXTRA_STREAM, uri); and another mime-type probably needs to be specified, just what it needs ... intent.setType("?/?"); - woesss
  • @RodGers I don’t know for sure, but always duplicate the last letter in the file extension ie .apk -> .apkk - Flippy

0