# How to link to a https url

**URL:** <https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894>\
**Category:** Android\
**Created:** [August 24, 2020, 8:15am UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894 "2020-08-24T08:15:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jose.rodriguez.an](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jose.rodriguez.an/32/7874_2.png) [@jose.rodriguez.an](https://discuss.kotlinlang.org/u/jose.rodriguez.an)\
**Post date:** [August 24, 2020, 8:15am UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894/1 "2020-08-24T08:15:24Z")

</div>

Hello,

I am new in Kotlin. With Android Studio I am trying to create a small apk with buttons or textview to link to a https. First I did it with WebView which works properly, the problem is that I can’t see pop up messages. So I am trying to open the links with a browser, but the url change to http instead https

In MainActivity.kt

```
val btnViajes = findViewById<Button>(R.id.viajes)
    btnViajes?.setOnClickListener() {
       val activityWebViajes = Intent(this,webViajes::class.java)
        startActivity(activityWebViajes)       

    }

```

In other activity.kt

```
 override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_web_viajes)

    background = findViewById<LinearLayout>(R.id.back) as LinearLayout
    mWebView = findViewById(R.id.webView)
    mWebView.loadUrl(""https:// ****/***";")

    val webSetting = mWebView.settings

    webSetting.javaScriptEnabled = true
    mWebView.webViewClient = WebViewClient()

} 

```

Also I have tried, searching google, in MainActivity.kt this:

```
    val btnViajes = findViewById<Button>(R.id.viajes)
    btnViajes?.setOnClickListener() {
     

       var url = "https:// ****/***";
        startActivity(Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(url)
        })

    }

```

The problem is the same it opens a browser with a link without https. I would like to know how to open https url in a browser.

---

<div class="post-metadata">

**Author:** ![Eliote](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/eliote/32/7934_2.png) [@Eliote](https://discuss.kotlinlang.org/u/Eliote)\
**Post date:** [August 24, 2020, 1:53pm UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894/2 "2020-08-24T13:53:04Z")

</div>

Hello, this is more of an Android question than a Kotlin one. Anyway what you did should work.  
I don’t know if will make any diference but try to pass the URI in the Intent constructor (I do it this way in some of my apps and I know it works):

```auto
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))

```

---

<div class="post-metadata">

**Author:** ![jose.rodriguez.an](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jose.rodriguez.an/32/7874_2.png) [@jose.rodriguez.an](https://discuss.kotlinlang.org/u/jose.rodriguez.an)\
**Post date:** [August 24, 2020, 3:29pm UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894/3 "2020-08-24T15:29:03Z")

</div>

Hi Eliote,

I still have the same issue, don’t understand why.

```
val btnViajes = findViewById<Button>(R.id.viajes)
    btnViajes?.setOnClickListener() {
    

       var url = "https:// ***/***";
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))

    }

```

---

<div class="post-metadata">

**Author:** ![Eliote](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/eliote/32/7934_2.png) [@Eliote](https://discuss.kotlinlang.org/u/Eliote)\
**Post date:** [August 24, 2020, 3:34pm UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894/4 "2020-08-24T15:34:41Z")

</div>

The problem is in the server of the URL, and has nothing to do with the code. Try to open it directly in a browser and you will see.

---

<div class="post-metadata">

**Author:** ![jose.rodriguez.an](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jose.rodriguez.an/32/7874_2.png) [@jose.rodriguez.an](https://discuss.kotlinlang.org/u/jose.rodriguez.an)\
**Post date:** [August 24, 2020, 3:52pm UTC](https://discuss.kotlinlang.org/t/how-to-link-to-a-https-url/18894/5 "2020-08-24T15:52:10Z")

</div>

I have found the issue. I had to put another slash at the end. https://_ **/** / instead https://__ **/** _ without that it didn’t work.
