설치 여부 확인하기
public boolean getPackageList() {
boolean isExist = false;
PackageManager pkgMgr = getPackageManager();
List mApps;
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mApps = pkgMgr.queryIntentActivities(mainIntent, 0);
try {
for (int i = 0; i < mApps.size(); i++) {
if(mApps.get(i).activityInfo.packageName.startsWith("com.kor.app")){
isExist = true;
break;
}
}
}
catch (Exception e) {
isExist = false;
}
return isExist;
}
외부 실행
Intent intent = getPackageManager().getLaunchIntentForPackage("com.kor.app");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//파라메터 넣기
intent.putExtra("my_text", "This is my text to send.");
startActivity(intent);
앱이 설치되어 있지 않다면 앱스토어로 이동합니다.
String url = "market://details?id=" + "com.kor.apptest";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
public boolean getPackageList() {
boolean isExist = false;
PackageManager pkgMgr = getPackageManager();
List
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mApps = pkgMgr.queryIntentActivities(mainIntent, 0);
try {
for (int i = 0; i < mApps.size(); i++) {
if(mApps.get(i).activityInfo.packageName.startsWith("com.kor.app")){
isExist = true;
break;
}
}
}
catch (Exception e) {
isExist = false;
}
return isExist;
}
외부 실행
Intent intent = getPackageManager().getLaunchIntentForPackage("com.kor.app");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//파라메터 넣기
intent.putExtra("my_text", "This is my text to send.");
startActivity(intent);
앱이 설치되어 있지 않다면 앱스토어로 이동합니다.
String url = "market://details?id=" + "com.kor.apptest";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
댓글
댓글 쓰기