PackageManager pm = this.getPackageManager();
//flags Additional option flags. Currently should always be 0.
List<ApplicationInfo> appList = pm.getInstalledApplications(0);
Iterator<ApplicationInfo> i = appList.iterator();
/* retrieve installed applications */
while ( i.hasNext() ) {
ApplicationInfo app = i.next();
if (!( app.packageName.equals("com.kakao.talk")))
continue;
Log.i("TAG", "applist, " + app.packageName + " class name is : " + app.className
+ "\n uid is : " + String.valueOf(app.uid));
}
/* get version code. Version code is an internal version number. */
try {
// 0 means none of the optional information is returned.
PackageInfo packageInfo = pm.getPackageInfo("kr.co.mbridge.applist", 0);
Log.i("TAG", "application version : " + String.valueOf(packageInfo.versionCode));
} catch (NameNotFoundException e) {
e.printStackTrace();
}
============ 실제 코드 ================
//flags Additional option flags. Currently should always be 0.
List<ApplicationInfo> appList = pm.getInstalledApplications(0);
Iterator<ApplicationInfo> i1 = appList.iterator();
/* retrieve installed applications */
while ( i1.hasNext() ) {
ApplicationInfo app = i1.next();
if (( app.packageName.equals("com.kakao.talk"))){
temp_app = 1;
}
}
Log.v(" int temp_app ", Integer.toString(temp_app));
if(temp_app == 1){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("kakaolink://sendurl?msg=" + URLEncoder.encode(subject) + "&url=" + URLEncoder.encode(link) + "&appid=[kr.co.mt]&appver=[1.0]"));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
startActivity(intent);
}else{
alert.setTitle( "카카오톡 미설치" );
// alert.setMessage( "안녕 난 케이라고해" );
alert.setPositiveButton( "확인", new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int which) {
dialog.dismiss(); //닫기
}
});
alert.show();
}
'개발도구 > aOS - 안드로이드 개발' 카테고리의 다른 글
[안드로이드 커니 소스] (0) | 2011.06.30 |
---|---|
[안드로이드] alertdialog 알랏메세지 (0) | 2011.06.17 |
[안드로이드] 스타뉴스 앱 (0) | 2011.06.16 |
[안드로이드] listview 에 row와 row 사이 divider 설정하기 (0) | 2011.06.16 |
[안드로이드] listview 에서 스크롤 할때 검정화면 나오면.. (0) | 2011.06.16 |