0
我使用此代碼,讓我發展的關鍵哈希的Facebook SDK產生keyhash
public class Myap extends Application {
@Override
public void onCreate() {
super.onCreate();
}
public void printHashkey()
{
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.vitmail.android",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}
}
但它每次生成相同的錯誤
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vitmail.android/com.vitmail.android.navbar_fragments.NavigationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
請告訴我哪裏是錯誤的?
你必須在stackoverflow上搜索'什麼是java.lang.NullPointerException'。 – ELITE