Passing selected files to App ?
Moderators: Hacker, petermad, Stefan2, white
Passing selected files to App ?
I have written an app that show differences between two text files.
Is there a way to select 2 files in TC (in 1 panel or in both) and pass those paths to my app?
Tom
Is there a way to select 2 files in TC (in 1 panel or in both) and pass those paths to my app?
Tom
Last edited by t_arn on 2011-07-14, 13:14 UTC, edited 1 time in total.
OK, found the custom button feature, but it's not working as expected:
I have defined a button "Launch app (main function)" and set the Parameters as follows:
extra:FilePath1:%P%N
extra:FilePath2:%T%N
In the onCreate method of my application I have following code:
Then, I selected a file in both panels and press my custom button. My application starts OK, but extras is always null and therefore no files are getting loaded and displayed.
Is this a bug in TC or am I doing something wrong?
Tom
I have defined a button "Launch app (main function)" and set the Parameters as follows:
extra:FilePath1:%P%N
extra:FilePath2:%T%N
In the onCreate method of my application I have following code:
Code: Select all
Bundle extras = getIntent().getExtras();
if (extras != null)
{
String fp = extras.getString("FilePath1");
if (fp!=null) fnLoadFile(fp,0);
fp = extras.getString("FilePath2");
if (fp!=null) fnLoadFile(fp,1);
}
Is this a bug in TC or am I doing something wrong?
Tom
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Strange, "extras" should not be null. TC adds the values with a different name, though: If you specify "FilePath1", the extras will be added with name "android.intent.extra.FilePath1". It's added via myIntent.putExtra(extraname,extrastring).
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I have updated my code as follows:
And yes, extras IS null. In the LogCat I see the message "getting extras", but then nothing else and the files are not being loaded.
The code as such works - I have verified that with another small test app.
Tom
Code: Select all
// get passed data and load files
Bundle extras = getIntent().getExtras();
Log.i(stProgramName, "getting extras");
if (extras != null)
{
Log.i(stProgramName, "getting extra values");
String fp = extras.getString("android.intent.extra.FilePath1");
if (fp!=null) fnLoadFile(fp,0);
fp = extras.getString("android.intent.extra.FilePath2");
if (fp!=null) fnLoadFile(fp,1);
}
The code as such works - I have verified that with another small test app.
Tom
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Strange, it works fine for me with the example in the help (to send two attachments to gmail). Does this example work on your device? The field used is extra:SUBJECT:File to set the subject field (extra2 is for string lists).
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Well, this example uses "send to app", while I tried "launch app (main function)". They don't seem to work the same way...should they?ghisler(Author) wrote:Strange, it works fine for me with the example in the help
With "send to app" I can successfully send the first marked file of the active panel (%P%N) to my app. But how do I send the first marked file of the other panel? In other TC versions this works with %T%M, but %M does not work here.
My app (taTextDiff) shows differences between 2 text files, so I need to be able to pass 2 files, not just one. Why is %T supported but not %M as well?
Tom
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Total Commander only supports parameters for "ACTION_VIEW" and "ACTION_SEND" commands, not for "ACTION_MAIN". Why? According to Adroid documentation "ACTION_MAIN" does not support parameters:
http://developer.android.com/reference/android/content/Intent.html#ACTION_MAIN
http://developer.android.com/reference/android/content/Intent.html#ACTION_MAIN
public static final String ACTION_MAIN
Since: API Level 1
Activity Action: Start as a main entry point, does not expect to receive data.
Input: nothing
Output: nothing
Constant Value: "android.intent.action.MAIN"
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com