~eliasnaur/gio

2 2

intent-filter for Android

Thomas Bellembois
Details
Message ID
<1d1140e8c0b96a52c1a8cc0a1cc423d313f6e39f.camel@gmail.com>
DKIM signature
pass
Download raw message
Hi,

Is there a way to add intent-filter for Gio apps on Android ?
I would like to make my app available in the list of applications while
using the "share" button for URL's.

Regards,

Thomas
Details
Message ID
<C3TOZNN61BWH.1IL7DMEZE7F4W@themachine>
In-Reply-To
<1d1140e8c0b96a52c1a8cc0a1cc423d313f6e39f.camel@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Mon Jun 29, 2020 at 11:40, Thomas Bellembois wrote:
> Hi,
>
> Is there a way to add intent-filter for Gio apps on Android ?
> I would like to make my app available in the list of applications while
> using the "share" button for URL's.
>

There's no facility for specifying Android intent-filters currently. You
include permissions by importing special packages (for example
"gioui.org/app/permission/bluetooth"), but I'm not sure how you would declare
intent-filters to the gogio tool.

One way could be to have a special global variables in your main package:

	package main

	import "gioui.org/app/android/intent

	var intentFilters = []intent.Filter{
		...
	}

the variables would be parsed by the gogio tool and included in the
resulting AndroidManifest.

Other ideas welcome.

Note that you can avoid these kind of platform-specific problems by building
the Gio Activity as an Android .aar with the `-buildmode archive` flag. See

	https://github.com/tailscale/tailscale-android

-- elias
Gregory Pomerantz
Details
Message ID
<3e0cee0a-e4db-fbd3-0710-d1c33e9c7bd5@wow.st>
In-Reply-To
<C3TOZNN61BWH.1IL7DMEZE7F4W@themachine> (view parent)
DKIM signature
pass
Download raw message
On 6/29/20 11:31 AM, Elias Naur wrote:
> There's no facility for specifying Android intent-filters currently. You
> include permissions by importing special packages (for example
> "gioui.org/app/permission/bluetooth"), but I'm not sure how you would declare
> intent-filters to the gogio tool.
>
> One way could be to have a special global variables in your main package:
>
> 	package main
>
> 	import "gioui.org/app/android/intent
>
> 	var intentFilters = []intent.Filter{
> 		...
> 	}
>
> the variables would be parsed by the gogio tool and included in the
> resulting AndroidManifest.
>
> Other ideas welcome.

For a cross-platform solution, I'm thinking we could do something like this:

     import (
         _ "gioui.org/app/mime" // "Content-Type: image/*"
     )

gogio would detect the import and parse the line comment. On android, 
this would tell gogio to add the appropriate intent filter to register 
the app as a handler for the specified mime type. The intents would be 
sent to the main GIo Activity -- I have not tried it but we should be 
able to get the Intent from a Fragment, I think with 
"getActivity().getIntent()". We would need additional syntax if the app 
developer wants to designate a different Activity to handle the incoming 
intents, but it should be possible to plug something like that in if it 
is useful.
Export thread (mbox)