慕蓋茨4494581
2023-10-13 16:25:10
我的應用程序中有一個按鈕可以啟動其他應用程序,我使用 Intent getpackagename。我設法呼叫并啟動其他應用程序,但需要在手機內(nèi)安裝該應用程序才能啟動。有沒有其他方法可以在不安裝應用程序的情況下啟動應用程序,或者這似乎不可能做到這一點?
1 回答

冉冉說
TA貢獻1877條經(jīng)驗 獲得超1個贊
您可以使用這個解決方案 -
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.myapp");
if(intent.resolveActivity(context.getPackageManager()) != null){? //Open app if installed
? ? startActivity(intent);
}else{//Send to play store to download or instant app solution
try {
? ? startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.example.myapp")));
} catch (ActivityNotFoundException anfe) {
? ? startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.example.myapp")));
}
}
添加回答
舉報
0/150
提交
取消