Intent to open Instagram user profile on Android

后端 未结 6 1610
清歌不尽
清歌不尽 2020-12-02 10:38

I\'m developing a social networking app and our users can connect their Instagram account to our service. I\'d like to open Instagram profiles directly in their official And

6条回答
  •  北海茫月
    2020-12-02 10:58

    Kotlin Version of @jhondge answer:

                val uriForApp: Uri = Uri.parse("http://instagram.com/_u/xxx")
                val forApp = Intent(Intent.ACTION_VIEW, uriForApp)
    
                val uriForBrowser: Uri = Uri.parse("http://instagram.com/xxx")
                val forBrowser = Intent(Intent.ACTION_VIEW, uriForBrowser)
    
                forApp("com.instagram.android")
    
                try {
                    startActivity(context, forApp, null)
    
                } catch (e: ActivityNotFoundException) {
                    startActivity(context, forBrowser, null)
    
                }
    

提交回复
热议问题