Twitter 鏈接正常,但 Play Store 鏈接 https://play.google.com/store/apps/developer?id=NK+Apps 點擊無反應。
缺少 CATEGORY_BROWSABLE 和 FLAG_ACTIVITY_NEW_TASK,系統無法正確匹配處理該 URL 的 Activity(Play Store App)。
Button playStoreBtn = findViewById(R.id.bDonate);
playStoreBtn.setOnClickListener(v -> {
String url = "https://play.google.com/store/apps/developer?id=NK+Apps";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
String packageName = "com.example.app"; // 目標應用包名
Uri uri = Uri.parse("market://details?id=" + packageName);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
market:// 直接喚起 Play Store,體驗更好,且避免網頁重定向延遲。