Android Question How to run a B4A application with a single parameter?

T201016

Active Member
Licensed User
Longtime User
Hi,
How to run a B4A application with a single parameter?
The parameter is to be a file that is to be opened by the running application for reading or writing.
 

drgottjr

Expert
Licensed User
Longtime User
it sounds to me like you want to share a file between applications. this is not
necessarily difficult. you need a file provider as middleman, and you simply set
up an intent to launch a specific activity to do something with that file. the
activity which is launched needs to know that a stream is available to it from an
intent. are you familiar with any of this?

since you say the file must be readable or writable (but not both?), it sounds to me
like you want to modify the file and return it to its original location. for that you will
need a file provider in activity #2 in order to send the modified file back. this
means that activity #1 must also be set up to know it's supposed to receive
such a stream.

your question is somewhat vague, so i'm basing my response on what i infer from
your question. what you actually had in mind may be completely different. i can't
say. the actual details will affect any suggested solutions. an intent may not
even be needed, depending on your launcher and launchée (eg 1, are we talking about
an application with 2 activities? eg 2, does activity #2 already hold a bunch of
files, and what you're really talking about is telling activity #2 to use a certain
file to which it already has full access? in which case, you only need to send the
file name to activity #2, not an actual file.) lots of questions.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

T201016

Active Member
Licensed User
Longtime User
Welcome
I will explain a little:
The application is to be about B4A. I meant my own application written in B4A, more specifically a text editor.

Action:
When you click on a text file in your phone's browser, the Editor should open the (.txt) file - that's it.

Thank you for your interest so far, I think he has already suggested something to me - (see # 2.)
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Welcome
I will explain a little:
The application is to be about B4A. I meant my own application written in B4A, more specifically a text editor.

Action:
When you click on a text file in your phone's browser, the Editor should open the (.txt) file - that's it.

Thank you for your interest so far, I think he has already suggested something to me - (see # 2.)

we're getting a little closer.

so, you will write a text editor in b4a, correct? and this editor will be launched when someone clicks on a file name, correct?

there are some problems. the biggest problem has to do with the file's being somewhere on the internet. this means you have to download the file first onto your device and then share it with your text editor.

you say:
When you click on a text file in your phone's browser, the Editor should open the (.txt) file

the phone's browser is, typically, chrome (there are other browsers). it is very unclear what you
mean by "you click on a text file in your phone's browser". how do you imagine this
happening? normally, if you see a reference to a file in a browser, it is a hypertext link. you
click on it and the browser will load the referenced file (if it can. otherwise, it will try to save it.)
technically, it is possible make the browser do something you want it to by injecting javascript,
but, in practice - in this case - it will be extremely difficult.

if the file were already downloaded (into your files/download folder), the user could very
easily click on it for sharing, and your text editor would appear as a target (you have to register
your editor, but that's not difficult). you need to explain exactly how a text file is "in your browser".
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

T201016

Active Member
Licensed User
Longtime User
To post #7
The 'parameter' word created confusion for me, as in Android we do not call any app with some parameter.
Anyway, intent receiving is the way to go for you, as has been suggested.

I suggested the idea of using the GPS location in the B4A application, where I can call eg OsmAnd Live from the B4A application along with the GPS position. I thought that, having GPS parameters, I can run another application.
 
Last edited:
Upvote 0

T201016

Active Member
Licensed User
Longtime User
To post #9
i think the OP is already familiar with that link. i just spotted another thread of his where he shares a text editor he wrote based on the link.
https://www.b4x.com/android/forum/threads/b4x-texteditor-save-and-load-external-files.134809/
so, i don't know what's going on at this point.
I meant, of course, the file explorer located on the phone ...

To post #6
Action:
When you click on a text file in your phone's browser, the Editor should open the (.txt) file - that's it.

After clicking on the selected text file in the file explorer, the presented Text Editor should open the (.txt) file - and that's all that's enough for me. Sorry for my poor English, hence the confusion maybe.
 
Last edited:
Upvote 0
Top