all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Emacs for Android] How to open file with an external app?
@ 2023-08-19 14:57 Antonio Romano via Users list for the GNU Emacs text editor
  2023-08-22 12:15 ` Po Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Romano via Users list for the GNU Emacs text editor @ 2023-08-19 14:57 UTC (permalink / raw)
  To: help-gnu-emacs

The android-browse-url function allows to open a website using the default browser. Alternatively it is also possible to invoke the share menu.

But is it possible to invoke the "Open with..." menu for a specific file? How can one achieve this?

Thanks in advance

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Emacs for Android] How to open file with an external app?
  2023-08-19 14:57 [Emacs for Android] How to open file with an external app? Antonio Romano via Users list for the GNU Emacs text editor
@ 2023-08-22 12:15 ` Po Lu
  2023-08-22 12:23   ` Po Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Po Lu @ 2023-08-22 12:15 UTC (permalink / raw)
  To: Antonio Romano via Users list for the GNU Emacs text editor
  Cc: Antonio Romano

Antonio Romano via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> The android-browse-url function allows to open a website using the
> default browser. Alternatively it is also possible to invoke the share
> menu.
>
> But is it possible to invoke the "Open with..." menu for a specific
> file? How can one achieve this?

By providing a file:// URI to android-browse-url (should the file be
accessible to all programs), or a content URI of the following form:

  content://org.gnu.emacs/PATH

where PATH is the URL-encoded absolute file name of the file being
opened.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Emacs for Android] How to open file with an external app?
  2023-08-22 12:15 ` Po Lu
@ 2023-08-22 12:23   ` Po Lu
  2023-08-22 14:49     ` Antonio Romano via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 6+ messages in thread
From: Po Lu @ 2023-08-22 12:23 UTC (permalink / raw)
  To: Antonio Romano via Users list for the GNU Emacs text editor
  Cc: Antonio Romano

Po Lu <luangruo@yahoo.com> writes:

> Antonio Romano via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
>> The android-browse-url function allows to open a website using the
>> default browser. Alternatively it is also possible to invoke the share
>> menu.
>>
>> But is it possible to invoke the "Open with..." menu for a specific
>> file? How can one achieve this?
>
> By providing a file:// URI to android-browse-url (should the file be
> accessible to all programs), or a content URI of the following form:
>
>   content://org.gnu.emacs/PATH

Scratch that: `android-browse-url' rewrites file URIs into their
content:// counterparts without user intervention.  It is not necessary
to provide a content URI yourself.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Emacs for Android] How to open file with an external app?
  2023-08-22 12:23   ` Po Lu
@ 2023-08-22 14:49     ` Antonio Romano via Users list for the GNU Emacs text editor
  2023-08-22 23:45       ` Po Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Romano via Users list for the GNU Emacs text editor @ 2023-08-22 14:49 UTC (permalink / raw)
  To: Po Lu; +Cc: help-gnu-emacs

Thank your for your help

> By providing a file:// URI to android-browse-url (should the file be
> accessible to all programs)

This works. I opened a buffer for "~/test.epub" and then eval'd the
following
(android-browse-url (concat ["file://"](file://) buffer-file-name))

And it indeed tries to open content://org.gnu.emacs/document/ciao.epub
(as stated in your second email)

However, articulating the question further, if I try to navigate into
"/content/storage/org.nextcloud.documents/2a3683ac919807f000715758ea81ef61%2F665/Ebooks/effectiveawk.epub"
and eval the expression above, it would simply prepend
"content://org.gnu.emacs/document" to the path.

> or a content URI of the following form:
> content://org.gnu.emacs/PATH

I tried the following
(android-browse-url
"content://org.nextcloud.documents/2a368.../Ebooks/effectiveawk.epub")
and got the following error:

java.lang.SecurityException: UID 10713 does not have permission to
"/content/storage/org.nextcloud.documents/2a3683ac919807f000715758ea81ef61%2F665/Ebooks/effectiveawk.epub"
[user 0]; you could obtain access using ACTION_OPEN_DOCUMENT or related
apis

But I'm pretty sure Emacs has the permission to access the Nextcloud
document provider, since i can open buffers in it without any
trouble. Maybe i got the URI wrong?

I can also open document provider in a file manager called MiXplorer: i
navigated Nextcloud through it and, strangely enough, it seems that
MiXplorer gives its own content URIs to files:

"content://com.mixplorer.file/1409260714!/Ebooks/effectiveawk.epub"

which, if gives as argument to (android-browse-url), makes the "Open
with..." menu appear.

Document providers look like a mess to me. What's the easiest way to
externally open files in "/content/storage/org.nextcloud/documents/"?

> `android-browse-url' rewrites file URIs into their content://
> counterparts without user intervention. It is not necessary to
> provide a content URI yourself.

>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Emacs for Android] How to open file with an external app?
  2023-08-22 14:49     ` Antonio Romano via Users list for the GNU Emacs text editor
@ 2023-08-22 23:45       ` Po Lu
  2023-08-23 10:05         ` Antonio Romano
  0 siblings, 1 reply; 6+ messages in thread
From: Po Lu @ 2023-08-22 23:45 UTC (permalink / raw)
  To: Antonio Romano; +Cc: help-gnu-emacs

Antonio Romano <n58r@pm.me> writes:

> I tried the following
> (android-browse-url
> "content://org.nextcloud.documents/2a368.../Ebooks/effectiveawk.epub")
>
> and got the following error:
>
> java.lang.SecurityException: UID 10713 does not have permission to
> "/content/storage/org.nextcloud.documents/2a3683ac919807f000715758ea81ef61%2F665/Ebooks/effectiveawk.epub"
>
> [user 0]; you could obtain access using ACTION_OPEN_DOCUMENT
> or related
> apis
>
> But I'm pretty sure Emacs has the permission to access the Nextcloud
> document provider, since i can open buffers in it without any
> trouble. Maybe i got the URI wrong?

These permissions are granted exclusively to Emacs, and transferring
them to other programs is not possible.

> I can also open document provider in a file manager called MiXplorer:
> i navigated Nextcloud through it and, strangely enough, it seems that
> MiXplorer gives its own content URIs to files:
>
> "content://com.mixplorer.file/1409260714!/Ebooks/effectiveawk.epub"

It's probably copying the file to a temporary location, which is
subsequently made available to other programs.

>
> which, if gives as argument to (android-browse-url), makes the "Open
> with..." menu appear.
>
> Document providers look like a mess to me. What's the easiest way to
> externally open files in "/content/storage/org.nextcloud/documents/"?

Probably what I outlined above: copy the file to a location in the Unix
VFS (outside /content or /assets), before providing the copy to other
programs.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Emacs for Android] How to open file with an external app?
  2023-08-22 23:45       ` Po Lu
@ 2023-08-23 10:05         ` Antonio Romano
  0 siblings, 0 replies; 6+ messages in thread
From: Antonio Romano @ 2023-08-23 10:05 UTC (permalink / raw)
  To: Po Lu; +Cc: help-gnu-emacs

 > These permissions are granted exclusively to Emacs, and transferring
 > them to other programs is not possible.

That's a pity.

 > Probably what I outlined above: copy the file to a location in the Unix
 > VFS (outside /content or /assets), before providing the copy to other
 > programs.

Seems like the best solution.

Thank you again for your help!




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-23 10:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-19 14:57 [Emacs for Android] How to open file with an external app? Antonio Romano via Users list for the GNU Emacs text editor
2023-08-22 12:15 ` Po Lu
2023-08-22 12:23   ` Po Lu
2023-08-22 14:49     ` Antonio Romano via Users list for the GNU Emacs text editor
2023-08-22 23:45       ` Po Lu
2023-08-23 10:05         ` Antonio Romano

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.