[問題] 內部app連結外部app問題

看板AndroidDev作者 (Evk)時間11年前 (2014/03/05 16:17), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串1/1
流程 優先 啟動已安裝外部app 否則 啟動Google Play 進行安裝 試過的可用方法 目前可啟動到Google Play 但安裝後卻也還是去到Google Play <= 想解決 理想狀況 程式優先順序 1.本身app內開啟已安裝外部app(未安裝程式就會程式Break 無法到第二程序判斷) 以上為問題點 使用方法為Intent getLaunchIntentForPackage 次要 2.開啟Google Play 進行安裝 相關程式碼附上 String sParam = "AppPackageName"; Intent intent; try{ try{ intent = getPackageManager().getLaunchIntentForPackage("AppPackageName"); startActivity(intent); } // Open app with Google Play app catch(android.content.ActivityNotFoundException anfe){ intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+sParam)); startActivity(intent); } } catch (android.content.ActivityNotFoundException anfe) { // Open Google Play website intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+sParam)); startActivity(intent); } 程式碼連結 https://gist.github.com/anonymous/e59d7c0f6b5e71159aea 一整天無解 還是Intent getLaunchIntentForPackage無法在這當中應用 請求大神幫忙解惑 謝謝! -- 當月不再圓 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.22.221.199

03/05 17:23, , 1F
請縮排,或放到置底文的各網站,這樣難以閱讀
03/05 17:23, 1F
已修改!抱歉 ※ 編輯: Akiraevk 來自: 211.22.221.199 (03/05 17:45) ※ 編輯: Akiraevk 來自: 211.22.221.199 (03/05 17:47) ※ 編輯: Akiraevk 來自: 211.22.221.199 (03/05 18:08)

03/07 23:28, , 2F
如果是自己的 APP,請嘗試 intent.setAction(packagename);
03/07 23:28, 2F
文章代碼(AID): #1J5js49Z (AndroidDev)