Android Question Asosiate file to App

DataProtec

Member
Licensed User
How can i assiate a file to my App, i have to send a Textfile to a new Installation of my App with some encrypted data inside. En-Decrypt Works fine, but when a client get the Mail and download the file, for e.g conf.dpn should oen the file with my App and get the String into a TexBox, like Word or Exel.
Thanks
 

DonManfred

Expert
Licensed User
you can try to add this to your manifest. note sure though whether it works or not.
Make sure to have the app run once with this manifest for it to work

B4X:
AddActivityText(Main,<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=".*\\.dpn" />
        <data android:host="*" />
    </intent-filter>)
 

DataProtec

Member
Licensed User
I installed the App as reléase, not in Debug and run the App
Then i saved the file received by Mail and tap on it, but get the message no App to open this file
Here my manifes as i did, maybee some is wrong there
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="5" android:targetSdkVersion="26"/>
<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.DarkTheme)
AddActivityText(Main,<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=".*\\.dpn" />
        <data android:host="*" />
    </intent-filter>)
'End of default text.
 

DataProtec

Member
Licensed User
I think no, it must work
If i try with known extensión like pdf, doc, txt, jpg it gives me a list of programms to open, but if i use
a unknown ext it does not.
Will try another way, if i get something i Will public here, other members have the same problema
It must be possible
 

DataProtec

Member
Licensed User
This Works and i get it inside my App, but don't know how to open this file.
I get as Path = content://com.android.externalstorage.documents/document/primary%3ADownload%2Fconf.dpn
Inside my App i have
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim In As Intent = Activity.GetStartingIntent   
    Dim Parametri As String = In.GetData
    
    If Parametri<>Null Then
        ' Apertura parametri
        Log(Parametri)
        Activity.LoadLayout("print")
        LabelInfo.Text="Print file: " & Parametri
    
    Else
        Log("Apertura App")
        Activity.LoadLayout("main")
    End If
End Sub
And the the Log(Parametri) holds this path, but how can i open this File ?
 
Top