androidandroid-intenttasker

Send file to app with intents using Tasker


Using the app "Total Commander" (Link) I can select a .csv file and 'Open with' my selected app, "My Budget Book" (Link - paid app). This opens up the app and promps the user if I want to import the data. I seek to do this, instead from Tasker.

One thing of note, which I find odd, I can't do it from my stock (Samsung S8+) file explorer?

tl;dr I need help recreating an intent for sharing a file to My Budget Book for import.

I contacted the developer of "My Budget Book" and they gave me this:

ImportCsvActivity:
        <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:mimeType="text/csv"
                android:pathPattern=".*\\.csv"
                android:scheme="content"
                tools:ignore="AppLinkUrlError"/>
            <data
                android:mimeType="text/csv"
                android:pathPattern=".*\\.CSV"
                android:scheme="content"
                tools:ignore="AppLinkUrlError"/>
        </intent-filter>
        <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:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.csv"
                android:scheme="file"/>
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.CSV"
                android:scheme="file"/>
        </intent-filter>

I have been trying to follow guides online using the Tasker Java actions but so far the most I can do is lauch the app on the 'Import CSV' page, but it doesn't prompt for import.

Using "Intent Intercept" (Link) I get this:

    intent:///storage/emulated/0/My%20Budget%20Book/TaskerImport_1584702040.csv#Intent;scheme=file;type=text/comma-separated-values;launchFlags=0x13100000;end 
------------ 
ACTION: android.intent.action.VIEW 
DATA: file:///storage/emulated/0/My%20Budget%20Book/TaskerImport_1584702040.csv 
MIME: text/comma-separated-values 
URI: intent:///storage/emulated/0/My%20Budget%20Book/TaskerImport_1584702040.csv#Intent;scheme=file;type=text/comma-separated-values;launchFlags=0x13100000;end 
FLAGS: 
FLAG_RECEIVER_FOREGROUND 
FLAG_ACTIVITY_FORWARD_RESULT 
FLAG_ACTIVITY_PREVIOUS_IS_TOP 
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY 

------------ 
MATCHING ACTIVITIES: 
Excel (com.microsoft.office.excel - com.microsoft.office.excel.excelMainActivity) 
anWriter free (com.ansm.anwriter - com.ansm.anwriter.MainActivityFree) 
Totalcmd-Editor (com.ghisler.android.TotalCommander - com.ghisler.android.TotalCommander.TCEditActivity) 
Sheets (com.google.android.apps.docs.editors.sheets - com.google.android.apps.docs.editors.trix.quicksheet.QuickSheetDocumentOpenerActivityAlias) 
CSV import (com.onetwoapps.mh - com.onetwoapps.mh.ImportCsvActivity) 
QuickEdit (com.rhmsoft.edit - com.rhmsoft.edit.activity.MainActivity) 

My current task:

Intent Testing (13)
    A1: Java Function [ Return:theIntent Class Or Object:Intent Function:new
{Intent} () Param:Intent.ACTION_SEND Param: Param: Param: Param: Param: Param: ] 
    A2: Java Function [ Return: Class Or Object:theIntent Function:setAction
{Intent} (String) Param:android.intent.action.VIEW Param: Param: Param: Param: Param: Param: ] 
    A3: Java Function [ Return: Class Or Object:theIntent Function:setClassName
{Intent} (String, String) Param:com.onetwoapps.mh Param:com.onetwoapps.mh.ImportCsvActivity Param: Param: Param: Param: Param: ] 
    A4: Java Function [ Return: Class Or Object:theIntent Function:addFlags
{Intent} (int) Param:theIntent.FLAG_ACTIVITY_NEW_TASK Param: Param: Param: Param: Param: Param: ] 
    A5: Java Function [ Return:parsedurl Class Or Object:Uri Function:parse
{Uri} (String) Param:file:///My Budget Book/TaskerImport_1584702040.csv Param: Param: Param: Param: Param: Param: ] 
    A6: Java Function [ Return: Class Or Object:theIntent Function:putExtra
{Intent} (String, Parcelable) Param:android.intent.extra.STREAM Param:parsedurl Param: Param: Param: Param: Param: ] 
    A7: Java Function [ Return: Class Or Object:CONTEXT Function:startActivity
{} (Intent) Param:theIntent Param: Param: Param: Param: Param: Param: ] 

Edit: I need help recreating the intent for sharing a file, generated by Tasker, to My Budget Book for import.

Any help is greatly appreciated, thank you!


Solution

  • Solved using Tasker ADB Wifi action:

    am start -a android.intent.action.VIEW -d file://%filepath -t text/comma/separated-values -n come.onetwoapps.mh/.ImportCsvActivity

    'Spaces' in file path name need to be converted to '%20'