private PackageManager packageManager = null;
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setPackage("com.google.android.youtube");
intent.putExtra("query", "diablo 3");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
packageManager = this.getPackageManager();
if (packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY) != null && packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
startActivity(intent);
}else{
openWebView();
}
//如果手機端有com.google.android.youtube則呼叫
//否則使用網頁開啟youtube網站
沒有留言:
張貼留言