Hello everyone,
here's how to run your own application (text editor) with the selected file.
This example allows you to open the contents of a text file (.txt) and an encrypted file (.weo) in mine
in the previous example, TextEditor.
However, I would rather research the file type in terms of its contents than just by the file extension,
but so far I have not found any other solution:
in the Manifest:
B4X:
In the code:
B4X:
here's how to run your own application (text editor) with the selected file.
This example allows you to open the contents of a text file (.txt) and an encrypted file (.weo) in mine
in the previous example, TextEditor.
However, I would rather research the file type in terms of its contents than just by the file extension,
but so far I have not found any other solution:
in the Manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
'FileProvider
AddApplicationText(
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="$PACKAGE$.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)
'IME
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
AddActivityText(Main,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:host="*" androidathPattern=".*\\.txt" />
<data android:scheme="https" android:host="*" androidathPattern=".*\\.txt" />
<data android:scheme="content" android:host="*" androidathPattern=".*\\.txt" />
<data android:scheme="file" android:host="*" androidathPattern=".*\\.txt" />
<data android:scheme="http" android:host="*" androidathPattern=".*\\.weo" />
<data android:scheme="https" android:host="*" androidathPattern=".*\\.weo" />
<data android:scheme="content" android:host="*" androidathPattern=".*\\.weo" />
<data android:scheme="file" android:host="*" androidathPattern=".*\\.weo" />
<data android:mimeType="*/*" />
</intent-filter>)
In the code:
B4X:
In the code::
Sub Activity_Create(FirstTime As Boolean)
Private In As Intent = Activity.GetStartingIntent
Private FileNameParameter As String = In.GetData
If FileNameParameter <> Null Then
MsgboxAsync(FileNameParameter,"Parameters")
... 'Open text editor with parameter.
If FileName <> *.txt or *.weo Then MsgboxAsync("The wrong file type has been select.", "Correct file: *.txt | *.weo")
ExitApplication
Else
... 'Open text editor without parameters.
End If
End Sub