Start Android app from javascript widget

This is a question I asked at a time (a long time ago in a galaxy far far away) before HADashboard was based on AppDaemon, so I will start a new thread.

I am running HADashboard on a tablet with Fully Kiosk Browser.

I want to start an android app on the tablet when clicking a widget in HADashboard. I am aware of the javascript widget, but how to use it is a mystery to me. I have had suggested to me this JavaScript command:

"intent://#Intent;package=com.orangebikelabs.orangesqueeze;action=com.orangebikelabs.orangesqueeze.actions.LAUNCH;end"

I have put that in a javascript widget, but that doesnā€™t seem to work. Clicking on the widget seems to do nothing.

Any help appreciated.

the javascript widget is about the most advanced that there is.
i havent even played with it because i am not good enough with javascript.

the command you put there must be a complete working command that can be placed in any html page.
i think that there are only a few people on this forum that know javascript well enough to even be able to answer this question.

when i want this kind of stuff i would start looking on google for ā€œstarting an android app from javascriptā€

the first thing i find then is this page:

in that page i see that something like your command is used as an url like this:

<a href="intent://my_host#Intent;scheme=my_scheme;action=my_action;end">Link to my stuff</a> 

with an action like

        <intent-filter>
            <action android:name="my_action"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="my_scheme" android:host="my_host" />
        </intent-filter>

that to me would suggest that you need to add that intentfilter to your skin and call that action by its name, or find a way to get that whole action in 1 working command.

all that the widget does is

eval(self.command);

so it must be a complete js function.

i suggest you start by trying to create a basic html page that contains a link to your app and start the app from that page.
you can save the page on your dashboard server in custom_css/html and call it with

http://daship:dashport/custom_css/html/yourpage.html

to test the page. if you got that working then you can start thinking about how to get it in your dashboard (and the easiest way at that moment is to use an iframe to the created page :wink: )

I think this reinforces the fact that I need to learn a whole lot more about JavaScript!

Thank you for your detailed reply. I have of course googled until I am cross-eyed about how to start an app with javascript, intents and all sorts of crap, and indeed I had spotted that stackoverflow page, and a score or more of others.

What I am really after I guess is a solid example of how to use the javascript widget, which has very minimal documentation on the AppDaemon docs.

Thank you again. I will continue research!

you are about the first i hear about that wants to use it :wink:
but the command must be something you add at this place action=my_action;end"
so you can put a jsscript with a function in your skin and then the command would be the name of the function.

like i said, the best way is first to create a working HTML page. if you have that working then post that and we can figure out together how to get it into the dashboard.

Thanks, Iā€™ll work on it!

1 Like

Any luck figuring it out? I need to launch an intent too

No, no luck at all.

This is the code I used with HADashboard to define a tile that would open another app:

app_netflix:
    widget_type: navigate
    title: Netflix
    url: "intent:#Intent;component=com.netflix.mediaclient/com.netflix.mediaclient.ui.launch.UIWebViewActivity;end"
1 Like

[quote=ā€œnickrout, post:1, topic:54534ā€]"
Fully
[/quote]

I solved it a different way, In Fully Kiosk Browser I setup a ā€œUniversal Launcher pageā€ containing all the Android apps that I want to be accessable.
On the HADasboard I then defined a javascript widget

fully:
    widget_type: javascript
    title: Launcher
    title2: Fully Kiosk Browser
    title2_style: "color: red; font-weight: 500; font-size: 75%"
    command: window.open("fully://launcher", "_self")
    icon_inactive: mdi-rocket

I tried the navigator widget but that adds the skin name to the URL (incl ā€˜?skin=defaultā€™ if no skin has been selected), which Fully canā€™t process.
The other issue is that a lot of Android apps donā€™t actually exit so the only way to get back to Fully is to use the ā€˜recent appsā€™ list (as far as I can tell).