Avoid NPE is options menu gets called before onResume (?)

git-svn-id: https://zxing.googlecode.com/svn/trunk@2264 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-04-26 16:53:42 +00:00
parent b81971bf74
commit a1601d1bb8

View file

@ -80,7 +80,8 @@ public final class EncodeActivity extends Activity {
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(Menu.NONE, SHARE_MENU, Menu.NONE, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share);
int encodeNameResource = qrCodeEncoder.isUseVCard() ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
menu.add(Menu.NONE, ENCODE_FORMAT_MENU, Menu.NONE, encodeNameResource)
.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
return true;