Skip to content

open a file or url in an external app, trigger android.intent.action.VIEW|SEND #153

Open
android-js/android-native-apis
#15
@PawelSuwinski

Description

@PawelSuwinski
Contributor

Hi

It could be nice feature apart to app.loadURL() to have also possibility to send to or view resource externally using android built-in app chooser having something like app.sendURL()|app.viewURL().

For now I do it on back process level by spawning ActivityManager process:

// view/index.html
document.querySelectorAll('#upload a').forEach(a => a.addEventListener('click', e => { 
  e.preventDefault();
  front.send('view', e.target.href);
})));
// main.js
back.on('view', file => require('child_process').execFile('am',
  [...'start --user 0 -a android.intent.action.VIEW -d'.split(' '), file],
  err => err && back.send('error', err)));

Activity

Chhekur

Chhekur commented on Dec 4, 2020

@Chhekur
Member

Hey @PawelSuwinski,
I am actually thinking to work on this for a long time but I didn't get a chance to work on this, if someone can contribute to the project and raise a PULL request will be the fastest way to build this.
But yeah I'll try to implement this as soon as I get time to work on this ; )

PawelSuwinski

PawelSuwinski commented on Dec 5, 2020

@PawelSuwinski
ContributorAuthor

I am rather on basic level with Java and Android SDK so I will not try to do any contribution, but I think good starting point could be with TermuxOpenReceiver implementation:

https://github.com/termux/termux-packages/blob/master/packages/termux-tools/termux-open
https://github.com/termux/termux-app/blob/master/app/src/main/java/com/termux/app/TermuxOpenReceiver.java

PawelSuwinski

PawelSuwinski commented on Dec 6, 2020

@PawelSuwinski
ContributorAuthor

After all I will try to, it could be some challange, but based on am system command execution by implementing app.exec():

#60 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @PawelSuwinski@Chhekur

      Issue actions

        open a file or url in an external app, trigger android.intent.action.VIEW|SEND · Issue #153 · android-js/androidjs