List of usage examples for android.content.pm Signature toByteArray
public byte[] toByteArray()
From source file:com.letsgood.sampleapp.SignInActivity.java
private void printFacebookKeyHash() { // Add code to print out the key hash try {/*from www .j a v a 2 s.c o m*/ PackageInfo info = getPackageManager().getPackageInfo("com.letsgood.sampleapp", 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) { } }
From source file:com.socialapp.eventmanager.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { userSkippedLogin = savedInstanceState.getBoolean(USER_SKIPPED_LOGIN_KEY); }// w w w . ja va2s.c om try { PackageInfo info = getPackageManager().getPackageInfo("com.socialapp.eventmanager", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); String keyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT); Log.d("************* KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) { checkAndRedirectOnFBLogin(); if (isResumed) { FragmentManager manager = getSupportFragmentManager(); int backStackSize = manager.getBackStackEntryCount(); for (int i = 0; i < backStackSize; i++) { manager.popBackStack(); } if (currentAccessToken != null) { // showFragment(SELECTION, false); } else { showFragment(SPLASH, true); } } } }; setContentView(R.layout.activity_login); FragmentManager fm = getSupportFragmentManager(); SplashFragment splashFragment = (SplashFragment) fm.findFragmentById(R.id.splashFragment); fragments[SPLASH] = splashFragment; FragmentTransaction transaction = fm.beginTransaction(); // for(int i = 0; i < fragments.length; i++) { transaction.hide(fragments[0]); // } transaction.commit(); splashFragment.setSkipLoginCallback(new SplashFragment.SkipLoginCallback() { @Override public void onSkipLoginPressed() { userSkippedLogin = true; //showFragment(SELECTION, false); } }); accessTokenTracker.startTracking(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String userLoggedIn = prefs.getString("email", null); if (userLoggedIn != null) { Intent intent = new Intent(this, MainActivity.class); startActivity(intent); } }
From source file:com.example.yudiandrean.socioblood.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //FacebookSdk.sdkInitialize(this.getApplicationContext()); setContentView(R.layout.activity_login); try {/*from w w w . j a va 2s.c om*/ PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 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) { } TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); //instantiate callbacks manager //mCallbackManager = CallbackManager.Factory.create(); inputEmail = (EditText) findViewById(R.id.email); inputPassword = (EditText) findViewById(R.id.password); Btnregister = (Button) findViewById(R.id.registerbtn); btnLogin = (Button) findViewById(R.id.login); passreset = (Button) findViewById(R.id.passres); // facebookLogin = (LoginButton) findViewById(R.id.facebook_login); //facebookLogin.setReadPermissions(permissionNeeds); session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(LoginActivity.this, FeedActivity.class); startActivity(intent); finish(); } // accessTokenTracker = new AccessTokenTracker() { // @Override // protected void onCurrentAccessTokenChanged( // AccessToken oldAccessToken, // AccessToken currentAccessToken) { // // App code // } // }; // // profileTracker = new ProfileTracker() { // @Override // protected void onCurrentProfileChanged( // Profile oldProfile, // Profile currentProfile) { // // App code // } // }; passreset.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(), PasswordReset.class); startActivityForResult(myIntent, 0); finish(); } }); Btnregister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(), Register.class); startActivityForResult(myIntent, 0); finish(); } }); /** * Login button click event * A Toast is set to alert when the Email and Password field is empty **/ btnLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if ((!inputEmail.getText().toString().equals("")) && (!inputPassword.getText().toString().equals(""))) { NetAsync(view); } else if ((!inputEmail.getText().toString().equals(""))) { Toast.makeText(getApplicationContext(), "Password field empty", Toast.LENGTH_SHORT).show(); } else if ((!inputPassword.getText().toString().equals(""))) { Toast.makeText(getApplicationContext(), "Email field empty", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Email and Password field are empty", Toast.LENGTH_SHORT).show(); } } }); // //facebook login // facebookLogin.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { // // // @Override // public void onSuccess(LoginResult loginResults) { // //login ok get access token // AccessToken.getCurrentAccessToken(); // // // } // // @Override // public void onCancel() { // // Toast.makeText(getApplicationContext(), // "Login Cancelled", Toast.LENGTH_SHORT).show(); // } // // // @Override // public void onError(FacebookException e) { // Toast.makeText(getApplicationContext(), // "Login Failed!", Toast.LENGTH_SHORT).show(); // } // }); //Session Manager // TwitterSession session = // Twitter.getSessionManager().getActiveSession(); // TwitterAuthToken authToken = session.getAuthToken(); // String token = authToken.token; // String secret = authToken.secret; //Guest Authentication TwitterCore.getInstance().logInGuest(new Callback<AppSession>() { @Override public void success(Result<AppSession> result) { AppSession guestAppSession = result.data; } @Override public void failure(TwitterException exception) { // unable to get an AppSession with guest auth } }); }
From source file:facebook.hellofriends.app.MyFaceBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {// ww w .j a va2 s. co m PackageInfo info = getPackageManager().getPackageInfo("com.example.in", 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)); System.out.println("Key hash::::::::::::" + md.digest() + " " + Base64.DEFAULT); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); logger = AppEventsLogger.newLogger(this); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.main); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { MyFaceBookActivity.this.user = user; updateUI(); System.out.println("hello:::::::::::::" + user); logger.logEvent(AppEventsConstants.EVENT_NAME_ACTIVATED_APP); logger.logEvent("Login Button pressed By " + user); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.amansoni.tripbook.activity.FacebookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add code to print out the key hash try {//w ww . j a v a 2 s.c o m PackageInfo info = getPackageManager().getPackageInfo("com.amansoni.tripbook", 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) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.facebook_activity); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { FacebookActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.namnv.project.kidpaint.HelloFacebookSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add code to print out the key hash try {//from ww w.j a v a 2s . c o m PackageInfo info = getPackageManager().getPackageInfo("com.facebook.samples.hellofacebook", 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) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.sample_main); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { HelloFacebookSampleActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.game.simple.Game3.java
private void printKeyHash() { // Add code to print out the key hash try {/* w w w.ja va 2 s .c o m*/ PackageInfo info = getPackageManager().getPackageInfo("com.game.simple", 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 (NameNotFoundException e) { Log.d("KeyHash:", e.toString()); } catch (NoSuchAlgorithmException e) { Log.d("KeyHash:", e.toString()); } }
From source file:util.facebook.FBManager.java
@Override public void onCreate(Bundle savedInstanceState) { if (Define.g_bDebugTest) { try {//from ww w. j a v a2 s . c om PackageInfo info = getApplicationContext().getPackageManager() .getPackageInfo("com.wh.BluffingGirlEN", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("GameApp", "GameApp:" + Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { Log.e("GameApp:" + "name not found", "GameApp:" + e.toString()); } catch (NoSuchAlgorithmException e) { Log.e("GameApp:" + "no such an algorithm", "GameApp:" + e.toString()); } } super.onCreate(savedInstanceState); //here to change fb application id for new session, //Define.MyLog(m_strAppID); //Session l_NewSession = new Session.Builder(getBaseContext()).setApplicationId(m_strAppID).build(); //Session.setActiveSession(l_NewSession); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.fbmanagerlayout); loginButton = (LoginButton) findViewById(R.id.login_button); if (loginButton != null) { loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { FBManager.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); } profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); //postPhotoButton = (Button) findViewById(R.id.postPhotoButton); //postPhotoButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View view) { // onClickPostPhoto(); // } //}); //pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); //pickFriendsButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View view) { // onClickPickFriends(); // } //}); //pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); //pickPlaceButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View view) { // onClickPickPlace(); // } //}); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:org.technovanza.technovanza14.HelloFacebookSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Parse.initialize(this, "jWNXwn3j7fmaub8bFMWYy3sRWJgXCMaqCljKOUyn", "AmQgVA2i3Gc45vHfYwqfPcJJzAyvwihvmgYcRx86"); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); try {// ww w .j av a 2 s . c o m PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); String sign = Base64.encodeToString(md.digest(), Base64.DEFAULT); Log.e("MY KEY HASH:", sign); Toast.makeText(getApplicationContext(), sign, Toast.LENGTH_LONG).show(); Log.d("mohit", "Signature" + sign); System.out.println("Signature" + sign); // TextView tvmyName = (TextView)findViewById(R.id.txtv); // /tvmyName.setText(Base64.encodeToString((md.digest())); } } catch (NameNotFoundException e) { Log.d("mohit", "Exception 1" + e); } catch (NoSuchAlgorithmException e) { Log.d("mohit", "Exception 2" + e); } if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.main); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { HelloFacebookSampleActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); inviteFriends = (Button) findViewById(R.id.inviteFriends); inviteFriends.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickInviteFriends(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); technoPage = (Button) findViewById(R.id.TechnoPage); technoPage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO Auto-generated method stub Intent facebookIntent = getOpenFacebookIntent(HelloFacebookSampleActivity.this); startActivity(facebookIntent); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.jrummyapps.android.safetynet.SafetyNetHelper.java
@SuppressLint("PackageManagerGetSignatures") private List<String> getApkCertificateDigests() { List<String> apkCertificateDigests = new ArrayList<>(); PackageManager pm = context.getPackageManager(); PackageInfo packageInfo;/*from www . ja v a2s . co m*/ try { packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException wtf) { return apkCertificateDigests; } Signature[] signatures = packageInfo.signatures; for (Signature signature : signatures) { try { MessageDigest md = MessageDigest.getInstance(SHA_256); md.update(signature.toByteArray()); byte[] digest = md.digest(); apkCertificateDigests.add(Base64.encodeToString(digest, Base64.NO_WRAP)); } catch (NoSuchAlgorithmException ignored) { } } return apkCertificateDigests; }