Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PawelSuwinski opened this issue Dec 4, 2020 · 3 comments · May be fixed by android-js/android-native-apis#15

Comments

@PawelSuwinski
Copy link
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)));
@Chhekur
Copy link
Member

Chhekur commented Dec 4, 2020

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants