Created
October 23, 2015 11:31
-
-
Save EvlinLee/37f27d2de24e1aab3d1d to your computer and use it in GitHub Desktop.
android getSignature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getSignature(View view) { | |
String pkgname = et_pkgname.getText().toString(); | |
boolean isEmpty = TextUtils.isEmpty(pkgname); | |
if (isEmpty) { | |
Toast.makeText(this, "应用程序的包名不能为空!", Toast.LENGTH_SHORT); | |
} else { | |
try { | |
/** 通过包管理器获得指定包名包含签名的包信息 **/ | |
packageInfo = manager.getPackageInfo(pkgname, PackageManager.GET_SIGNATURES); | |
/******* 通过返回的包信息获得签名数组 *******/ | |
signatures = packageInfo.signatures; | |
/******* 循环遍历签名数组拼接应用签名 *******/ | |
for (Signature signature : signatures) { | |
builder.append(signature.toCharsString()); | |
} | |
/************** 得到应用签名 **************/ | |
signature = builder.toString(); | |
tv_signature.setText(signature); | |
} catch (NameNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment