Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a URL from terminal

Tags:

android

unix

I'm writing a script to run on android's terminal and I need it to open the browser and a URL. I managed to open the browser but didn't find a way to put the URL on it.

am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity;

Appreciate any help : )

like image 547
Adami Avatar asked May 10 '13 17:05

Adami


People also ask

How do I open a URL in Ubuntu terminal?

On Linux, the xdc-open command opens a file or URL using the default application. To open a URL using the default browser… On Mac, we can use the open command to open a file or a URL using the default application. We can also specify what application to open the file or URL.

How do I open a link in Linux?

xdg-open command in the Linux system is used to open a file or URL in the user's preferred application. The URL will be opened in the user's preferred web browser if a URL is provided. The file will be opened in the preferred application for files of that type if a file is provided.


1 Answers

Just use Intent.ACTION_VIEW (i.e. android.intent.action.VIEW), e.g.:

am start -a android.intent.action.VIEW -d http://www.xing.de

This way the XING site is started. If you have more than one browser installed, you can of course add the component name of the browser you want to start, e.g.:

am start -a android.intent.action.VIEW 
         -n com.android.browser/.BrowserActivity -d http://www.xing.de

Cheers!

like image 52
Trinimon Avatar answered Sep 28 '22 09:09

Trinimon