Sharing data to AI2, not sharing data from AI2

Hi Taifun,
Thank you for your kind reply.
I submitted exactly the same question yesterday in my topic here: https://community.appinventor.mit.edu/t/catch-text-data-sent-by-android-share-menu/14459) and it looks funny that Steve_Silberberg did the same question just some hours later! :smile:
That's a pity such feature is available in Kodular, but not in App Inventor. I am really involved in this matter and now I am even more eager as I know somebody else is looking for the same feature.
So, I am just attempting to implement this feature by an extension, but unfortunately my Java skills are quite poor and I am experiencing several issues. Here below there is the Java code extension I somehow wrote, but I can't compile it:

SalvyGetSharedText.java.txt (3.4 KB)

I am pretty sure the error is related to Intent and getIntent() method usage: as far as I know, they should come from Activity class or something like that, but I don't know how to solve and move on. I noticed you used getIntent() method in your Clipboard extension, but I can't figure how you did.
Any help would be very appreciated.
Thank you again.

Hi @Salvatore_Oliva
I checked the file and found that you have only implemented blocks to get shared file/text.
To be able to show your app in Share to list you will have to add specific mime types in manifest with the help of @UsesActivities.
Here is an example of it:

Also check this if you don't want users to compile the extension everytime:
https://deep-link.000webhostapp.com/

2 Likes

Hi Sunny, thank you for your kind feedback.
Actually, I already solved the issue about editing Manifest file in order to add the proper Intent filter for mime text type (I unpacked and packed again APK app by APK Editor Studio): I can find my app listed in Share menu, but I can't figure out a way to pull and retrieve the shared text block in my app (I already tried by get plain start text block included in Screen1.Initialize event, but it does not work)...
So I eventually decided to attempt a different path, by building up a specific AI2 extension, with the purpose to receive and handle the sharing Intent: now my problem is different and it is about my Java code of the extension, that does not compile:

As far as I can understand (unfortunately my Java skill are quite limited), getIntent() method belongs to Activity class, that should somehow be extended by my component class, but at this point I am stuck.
Any helpful suggestion? @Taifun: which is your opinion? I have seen indeed you used that method in your Clipboard extension.
Thanks all again. Until next time.

no need to create your own extension...
just follow the advice by @vknow360 and use the DeepLink extension template... just add your desired scheme and host and build your individual extension
see also

Taifun

You are correct.
You can do two things:
1.Create a subclass which extends Activity
2.Create a class which extends Activity and

put it in same package

It seems that you have not checked that repo.
You don't have to do very much.Just edit UsesActivities annotation and set onCreate method.

It makes me a little confused :sweat_smile:
Btw, this topic should be in Open Source Development category.

2 Likes

Hi Sunny,
I examined attentively DeepLink repository and I found your project very interesting and useful. Actually, it seems exactly what I am looking for, with a little difference: I would like to highlight a block of text within any Android app, then long tap, select Share item in pop-up menu and send that block to my app, that should eventually get it. As far as I see, your extension looks rather capable to process and filter an hyperlink the user taps on, in order to decide if it has to be opened by an AI2 app.
Anyway, I think your approach is good and I feel I am on the right way, so I tried to somehow modify your Java file as per your suggestions, in order to fit it to my need, but, after several attempts fiddling with @UsesActivities section, I could not make it work. Here below there is Java file I edited:

DeepLink.java.txt (2.6 KB)

Where am I wrong? May be necessary modify as well OnCreate() method code accordingly? If so, how?
Thank you so much again for your kind and patient support.

1 Like

Here is the working code:
ReceiveShared.txt (3.8 KB)

Aix:
com.sunny.ReceiveShared.aix (7.3 KB)

Blocks:
image

4 Likes

Hi Sunny,
Outstanding work!!! :clap: :clap: :clap:
I can't really find any proper word to express my wonder and my gratitude! :astonished:
After having a look into your Java code, I feel astonished and I honestly acknowledge I would not have solved by myself as newbie. Besides, you did even more than I needed for: your extension is actually capable to share any kind of data: text, pictures, media. My sincere congratulations for your advanced problem solving skills and your deep Java knowledge.
Thank you so much a lot, you are great!
Since this turns out to be a valuable work, let me just suggest you to submit this project to a Github repository, even better you could merge it with your DeepLink project.
My sincere respect and many thanks again! :bowing_man: :handshake:
Salvatore

1 Like

Hey, Hi,

i am really new to this MIT App Inventor and i came across this page while i am looking for a process to make my application visible in share menu (when user clicks on share along with available applications my app also needs to be available) i don't really understand how this can be achieved or what needs to be done.

could you please help with my query

Hey! I've tested your extension and it works somehow, the problem is that if i share a .txt file the value is the filename and not the text inside the file... is there a way to get the contents of the file?

Have a great day! :slight_smile:

Yes that's the default behaviour but you can text by using File component, if you have required permission to access that file.

Hm, the name i get is just somename.txt (example)
how should i get the file from this?


The problem is that the file module has problems loading the file with spaces in the name... but if i replace " " with "%20" it says that the file could not be found...

the android file structure is not html driven.

There is a bug with regard to spaces in file paths. There is little point trying to fight it until it is fixed.

1 Like

what do you mean with that? what should i change in the filename to load it with spaces?

Can you print the file name on a label?

Sorry for the late response, i wasnt at home for a few days...

Yea i can print it :slight_smile:

Well, then do it. :grinning:

It prints just the name of the file.... "Name of the file.txt"
if i replace the spaces with %20 it prints: "Name%20of%20the%file.txt"

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.