Why Isn't My App on the List of Apps to Open Txt File

Why isn't my app on the list of apps to open txt file?

You need to associate your app with file extension. To do so, add these two line within intent filter and u'r good to go

<data android:scheme="file" />
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.pdf" />

And your manifest would be look like this

<activity name="com.your.activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
</activity>

<data android:scheme="file" /> => this define that the file must be local, not from http or else

<data android:mimeType="*/*" /> => match any mime type

<data android:pathPattern=".*\\.txt" /> => this is where you specify what extension you want to match

Hope this help

Phone doesn't show my application to open txt-files

That's why I created a broadcast receiver

A BroadcastReceiver is not used to open documents this way. An Activity does that.

But if I try to open a txt-file on my phone on where the application is installed it does not show my application.

That is because other apps will use startActivity(), not sendBroadcast(), with ACTION_VIEW Intents.

Create an activity and use your <intent-filter> with it. It should work with a few apps, though not very many. Eliminating <data android:pathPattern=".*\\.txt"/> and <data android:host="*"/>, and adding <data android:scheme="content"/>, will help increase compatibility.

Get content from txt file and put it in a list Flutter/Dart

Create an assets folder in your project, in your pubspec.yaml specify the asset (make sure it's in your assets folder, that the file exists and is readable)

flutter:
assets:
- assets/jobs.txt

Now you can access your text file like so -

import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;
Future<String> loadAsset() async {
return await rootBundle.loadString('assets/jobs.txt');
}

When the function returns your text, you can split it by commas and loop through all the jobs as you wish

Windows 10 Universal App File/Directory Access

In UWP apps, you can only access the following files and folders:

  • Directories which are declared in the manifest file (e.g. Documents, Pictures, Videos folder)
  • Directories and files which the user manually selected with the FileOpenPicker or FolderPicker
  • Files from the FutureAccessList or MostRecentlyUsedList
  • Files which are opened with a file extension association or via sharing

If you need access to all files in D:\, the user must manually pick the D:\ drive using the FolderPicker, then you have access to everything in this drive...

UPDATE:

Windows 10 build 17134 (2018 April Update, version 1803) added additional file system access capabilities for UWP apps:

  • Any UWP app (either a regular windowed app or a console app) that declares an AppExecutionAlias is now granted implicit access to the files and folders in the current working directory and downward, when it’s activated from a command line. The current working directory is from whatever file-system location the user chooses to execute your AppExecutionAlias.

  • The new broadFileSystemAccess capability grants apps the same access to the file system as the user who is currently running the app without file-picker style prompts. This access can be set in the manifest in the following manner:

    xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
...
IgnorableNamespaces="uap mp uap5 rescap">
...
<Capabilities>
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>

These changes and their intention are discussed at length in the MSDN Magazine article titled Universal Windows Platform - Closing UWP-Win32 Gaps. The articles notes the following:

If you declare any restricted capability, this triggers additional
scrutiny at the time you submit your package to the Store for
publication. ... You don’t need an AppExecutionAlias if you have this
capability. Because this is such a powerful feature, Microsoft will
grant the capability only if the app developer provides compelling
reasons for the request, a description of how this will be used, and
an explanation of how this benefits the user.

further:

If you declare the broadFileSystemAccess capability, you don’t need to
declare any of the more narrowly scoped file-system capabilities
(Documents, Pictures or Videos); indeed, an app must not declare both
broadFileSystemAccess and any of the other three file-system
capabilities.

finally:

Even after the app has been granted the capability, there’s also a
runtime check, because this constitutes a privacy concern for the
user. Just like other privacy issues, the app will trigger a
user-consent prompt on first use. If the user chooses to deny
permission, the app must be resilient to this.



Related Topics



Leave a reply



Submit