INTENT ID (Share intents and anothers important Intents)

Douglas Farias

Expert
Licensed User
Longtime User
How can i open the Dialog? So the user can choose the app?

if i use this:

B4X:
Private intent As INTENTID
If intent.IsInitialized = False Then intent.Initialize
intent.ShareImage(File.DirInternalCache,"mypic.png")
then it open every time snapchat.

when you select one app, the device set it the default app, you can reset manually on the device config, on Default Apps.

You can try force the code to open all the apps on the dialog.

try this code, if works i will update the lib in 2 or 3 days. (i m not on pc at this moment :))

B4X:
Dim u As Uri
u.Parse("file://" & File.Combine(folder,imagefile))
Dim i As Intent
i.Initialize(i.ACTION_SEND,"")
i.SetType("image/*")
i.PutExtra("android.intent.extra.STREAM",u)
i.WrapAsIntentChooser("Select")
StartActivity(i)
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Thanks it works. But it doesnt work if the pic comes from the cache, then i receive a blackscreen. But this is not the problem :)

and this is the code for text and pic together:

B4X:
Dim u As Uri
        u.Parse(File.Combine("file://" & File.DirDefaultExternal,"mypic.png))
        Dim i As Intent
        i.Initialize(i.ACTION_SEND,"")
        i.SetType("*/*") 
        i.PutExtra("android.intent.extra.TEXT", "I found this Picture in this App.")
        i.PutExtra("android.intent.extra.STREAM",u)
        i.WrapAsIntentChooser("Select")
        StartActivity(i)
 
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
Hi.
I m updated the lib to version 1.5

Added the (showAllsupportedApps As Boolean) function on
-ShareText
-ShareImage
-Share_TextandImage
-Share_Audio
-Share_File

Now when you want clear the default share app, just set showAllsupportedApps = true.
Example:
B4X:
intent.ShareImage(File.DirAssets,"14-29.jpg",False)
This code will show all apps with support to share text on it.
If you select whatsapp, on the next time when you share the image will share direct on whatsapp, will not show all apps with support at text. (will set whatsapp a default text share app.)

now with this code
B4X:
intent.ShareImage(File.DirAssets,"14-29.jpg",True)
if showAllsupportedApps = true, will show all apps with support at text, every time, this code force to show all apps, and dont set any select as default.


The lib 1.5 is on the first post
thx
 

riccardomarchetto

Member
Licensed User
Longtime User
Hi Douglas,
really a good job!

I have a problem only in the ShareMultipleFilesOn_Intent because when I call, it open always the last intent (for example whatsapp)

Please, can I ask you if it is possible to modify the

intent.ShareMultipleFilesOn_Intent(Array() as string,"")

like the "shareimage", adding at the end the parameter "ShowAllSupportedApps"?

THank you in advance
 

riccardomarchetto

Member
Licensed User
Longtime User
Have a look.

B4X:
intent.showAllsupportedApps = true

Thank you Alexander, ok, ... but I don't found the 'intent.showAllsupportedApps=true' properties in the 1.5.

with this code it works very well but I can send only 1 file:
B4X:
intent.ShareImage(File.DirAssets,"14-29.jpg",False)


But I asked if it is possible to put the "showAllsupportedApps" also in the 'ShareMultipleFilesOn_Intent' because when you try to share the second time you can't decide the app to use (it use the previous selected app like explain in #41)

thank you in advance
R
 

incendio

Well-Known Member
Licensed User
Longtime User
Downloaded example, tried to run and got error :
Missing library Device Id.

Comment lines that related to DeviceID lib seem works OK.
I guest this library not used in this example.

Great library ! Thanks for sharing.
 
Last edited:

JohnC

Expert
Licensed User
Longtime User

JohnC

Expert
Licensed User
Longtime User
You don't need any library to create and share data based on intents. It is likely that this library was implemented before FileProvider was required so it will not work anyway.

Search for FileProvider for more information.
I agree with the part that sends files that this lib might be using the old method and will not work.

But I was hoping to see if the OP could offer the details of all the different intents he compiled together, like:

1) Where was the URI placed in the intent (in the initialization part or elsewhere)
2) What was inserted as "data" and was as "Extra", etc.
3) What were the different package names used to target the intent to specific apps.

Yes, all of the above can probably be found, but only after a lot of searching.

I was just hoping to gain a "master" list of the details of different intents that the OP's already researched and tested.
 

PacoViv

Member
Licensed User
Thanks Erel.
I'm interested now only in some intents, and I see that:
INTENT.OpenCompany_GooglePlay
Works, at least in Android 7.1.1 and maybe it should not work on it.
i have not devices with newer Android versions to test.
Would it work in newer Android versions like 10?
If yes, that's the reason for my interest in the example for other share intents, like whatsapp, facebook
 

Douglas Farias

Expert
Licensed User
Longtime User
Hi all. this is a old lib.
i made it on 2016...
I'm trying to find the example but my old HD burned, unfortunately I think it will not be possible.
Anyway if you need help post on the forum that I try to help, I remember that I took the intents everything on the internet and converted it to B4A.
All from stackoverflow.

@Erel if you want to delete this thread, I believe it would be better not to cause problems.
 

JohnC

Expert
Licensed User
Longtime User
@Erel if you want to delete this thread, I believe it would be better not to cause problems.
Please don't delete this thread - this thread still contain valuable posts and info even if others are outdated.

Now that we know the OP doesn't have the example.zip, maybe someone else does and we can post it here and will be helpful for the functions that don't require fileprovider.
 
Top