Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to get my app to appear in the Android share dialog ?
Started by solca Nov 19 2018 12:01 PM

3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

solca

[GLOBAL: userInfoPane.html]
solca
  • Enthusiast

  • 53 posts
  • Corona SDK

Hi,

 

How to get my app to appear in the Android share dialog?
(For example when a user located in the photo gallery and want to share an image with my app)
 
I understand that the main.lua I should put something like this to receive the information:
 
local json = require("json")
local launchArgs = ...
print("### --- Launch Arguments ---")
if launchArgs == nil then
	print ("launchArgs is null")
else
	print( json.prettify( launchArgs ) )
end
 
But, should I configure something in the build.settings file? Or have something else in mind?
 
Thanks in advance for your answers,
 
solca


[TOPIC: post.html]
#2

xnailbender

[GLOBAL: userInfoPane.html]
xnailbender
  • Contributor

  • 357 posts
  • Corona SDK

soica,

 

You will need to get the plugin cnkFileManager from the Marketplace, link is on the thread link below.  I'll say it again, the is an Awesome Free Plugin!

 

Not sure what you have, but you need to add this to your build settings:

    plugins =
    {
        
        ['plugin.cnkFileManager'] = 
        {
            publisherId = 'es.cnksoft',
            supportedPlatforms = {  android=true }
        },
    },

android =   --these permissions allow phone access
    {
        usesPermissions =
        {
            "android.permission.INTERACT_ACROSS_USERS",
            "android.permission.WRITE_EXTERNAL_STORAGE",
            "android.permission.READ_EXTERNAL_STORAGE",
            
        },
        usesFeatures =
        {
            { name="android.hardware.camera", required=false },
            { name="android.hardware.location", required=false },
            { name="android.hardware.location.gps", required=false },
        },
        intentFilters =
        {
            -- This is the intent filter that WORKS!
            
            {
                label = "AnyLabelHere",
                
                actions = { "android.intent.action.VIEW",
                    "android.intent.action.EDIT",
                    "android.intent.action.GET_CONTENT",
                },
                categories =
                {
                    "android.intent.category.DEFAULT",
                    "android.intent.category.BROWSABLE",
                    "android.intent.category.OPENABLE",
                },
                
                data = 
                {   scheme="file",
                    
                    mimeType="application/fileExtensionYourAppOpensHere",  --possibly png as extension opens app

                },
                
            }, 
        },
    },
            

Now, go take a look at this thread for a good start on the rest of the code you need. It's not pretty, but gets the job done.

 

The launchArgs and onSystemEvent functions are setup to work with both iOS and Android.  You will have to modify as needed depending what file extensions you app opens.

 

Android Share Link

 

Let me know how things go.

 

Hope this helps,

 

Nail



[TOPIC: post.html]
#3

solca

[GLOBAL: userInfoPane.html]
solca
  • Enthusiast

  • 53 posts
  • Corona SDK

Thanks Nail for your response. However I see that it is oriented to share from the appCorona. You correct me if I'm wrong, please.
 
The situation is more or less this: A user is in the image gallery and want to share an image with my appCorona. my appCorona is suspended or closed at that time. The user selects the file and requests the share dialog. At that time, Android calls a menu of applications but there is not my appCorona.
 
What should I do to make my appCorona appear in that menu? (and that it can be executed)
 
Thanks again,
 
solca


[TOPIC: post.html]
#4

xnailbender

[GLOBAL: userInfoPane.html]
xnailbender
  • Contributor

  • 357 posts
  • Corona SDK

Soica,

 

The Android intents are similar to the iOS Open URL scheme.

 

I'd experiment with my code above and see what happens, it may be just what you are looking for.

 

I haven't actually tried to show my app from the Android gallery, but think it may work.

 

Curious, have you been able to have you app show in the Share Dialog box from the photo gallery on iOS?

 

That is one I haven't been able to figure out.

 

Nail




[topic_controls]
[/topic_controls]