List of usage examples for android.content.pm PackageManager GET_SIGNATURES
int GET_SIGNATURES
To view the source code for android.content.pm PackageManager GET_SIGNATURES.
Click Source Link
From source file:com.pseudosudostudios.jdd.activities.WinActivity.java
private void printFacebookInfo() { if (!isUserDebuggable()) return;// ww w . ja va 2s .co m try { 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 (NameNotFoundException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }
From source file:fe.up.pt.partner.FacebookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); Bundle b = getIntent().getExtras();//w w w .ja v a 2 s. c om title = b.getString("title"); author = b.getString("author"); rating = b.getString("rating"); /* * este bloco para imprimir a ash para depois se colocar no * site da app no facebook */ try { PackageInfo info = getPackageManager().getPackageInfo("fe.up.pt.partner", 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) { } catch (NoSuchAlgorithmException 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) { 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); text_box = (EditText) findViewById(R.id.share_text); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); cancelButton = (Button) findViewById(R.id.cancel_button); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { finish(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); // 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); } } }); }
From source file:com.igames2go.t4f.Activities.LoginPage.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApplication = ((T4FApplication) getApplication()); mApplication.setPlay_mode(T4FApplication.PLAY_MODE_LOGIN); try {/*from w w w . j av a2 s . co m*/ PackageInfo info = getPackageManager().getPackageInfo("com.igames2go.t4f", PackageManager.GET_SIGNATURES); for (android.content.pm.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) { } catch (NoSuchAlgorithmException e) { } setContentView(R.layout.main); pref = getSharedPreferences("user_info", MODE_PRIVATE); mApplication = (T4FApplication) getApplication(); app_id = getResources().getString(R.string.appid); inputEmail = (EditText) findViewById(R.id.emailText); inputPassword = (EditText) findViewById(R.id.passwordText); btnLogin = (ImageButton) findViewById(R.id.loginButton); btnSignUp = (ImageButton) findViewById(R.id.signupButton); btnForgot = (ImageButton) findViewById(R.id.forgotButton); btnNoLoginPlay = (ImageButton) findViewById(R.id.noLoginPlayButton); btnHowToPlay = (ImageButton) findViewById(R.id.howToPlayButton); btnHelp = (ImageButton) findViewById(R.id.helpButton); //loginErrorMsg = (TextView) findViewById(R.id.loginErrorMsg); inputEmail.setText(pref.getString("user_email", "")); inputPassword.setText(pref.getString("user_password", "")); btnLogin.setOnClickListener(this); btnSignUp.setOnClickListener(this); btnForgot.setOnClickListener(this); btnNoLoginPlay.setOnClickListener(this); btnHowToPlay.setOnClickListener(this); btnHelp.setOnClickListener(this); }
From source file:net.wequick.small.Small.java
public static void preSetUp(Application context) { sContext = context;//from w ww .java 2 s .co m // Register default bundle launchers registerLauncher(new ActivityLauncher()); registerLauncher(new ApkBundleLauncher()); registerLauncher(new WebBundleLauncher()); PackageManager pm = context.getPackageManager(); String packageName = context.getPackageName(); // Check if host app is first-installed or upgraded int backupHostVersion = getHostVersionCode(); int currHostVersion = 0; try { PackageInfo pi = pm.getPackageInfo(packageName, 0); currHostVersion = pi.versionCode; } catch (PackageManager.NameNotFoundException ignored) { // Never reach } if (backupHostVersion != currHostVersion) { sIsNewHostApp = true; setHostVersionCode(currHostVersion); } else { sIsNewHostApp = false; } // Collect host certificates try { Signature[] ss = pm.getPackageInfo(Small.getContext().getPackageName(), PackageManager.GET_SIGNATURES).signatures; if (ss != null) { int N = ss.length; sHostCertificates = new byte[N][]; for (int i = 0; i < N; i++) { sHostCertificates[i] = ss[i].toByteArray(); } } } catch (PackageManager.NameNotFoundException ignored) { } // Check if application is started after unexpected exit (killed in background etc.) ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName launchingComponent = am.getRunningTasks(1).get(0).topActivity; ComponentName launcherComponent = pm.getLaunchIntentForPackage(packageName).getComponent(); if (!launchingComponent.equals(launcherComponent)) { // In this case, system launching the last restored activity instead of our launcher // activity. Call `setUp' synchronously to ensure `Small' available. setUp(context, null); } }
From source file:org.ambientdynamix.web.WebUtils.java
/** * Returns the X509Certificate for the incoming packageName. Returns null if the packageName cannot be found (or if * there was a certificate exception)./*from w w w .j a v a2s.c om*/ */ public static X509Certificate getCertForApp(String packageName) { try { // Create packMgr, if needed if (packMgr == null) { packMgr = DynamixService.getAndroidContext().getPackageManager(); } // Create certFactory, if needed if (certFactory == null) { certFactory = CertificateFactory.getInstance("X509"); } PackageInfo packageInfo = packMgr.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); Signature[] signatures = packageInfo.signatures; // signatures[0] is a DER encoded X.509 certificate byte[] cert = signatures[0].toByteArray(); InputStream input = new ByteArrayInputStream(cert); X509Certificate c = (X509Certificate) certFactory.generateCertificate(input); return c; } catch (NameNotFoundException e) { Log.w(TAG, "Package not found for " + packageName + " - " + e); } catch (CertificateException e) { Log.w(TAG, "Certificate exception for " + packageName + " - " + e); } return null; }
From source file:com.smashedin.facebook.HelloFacebookSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {/* w w w .j a v a 2s . c o m*/ PackageInfo info = getPackageManager().getPackageInfo("com.smashedin.smashedin", 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) { } catch (NoSuchAlgorithmException e) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); 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(); } }); Bundle extras = getIntent().getExtras(); if (extras != null && extras.containsKey(EXTRA_ACCOUNTNAME)) { mEmail = extras.getString(EXTRA_ACCOUNTNAME); getTask(HelloFacebookSampleActivity.this, mEmail, SCOPE).execute(); } /* LinearLayout nevermind = (LinearLayout) findViewById(R.id.nevermind); nevermind.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Singleton.getInstance().m_bnevermind = true; finish(); } }); */ }
From source file:com.yalin.apkparserdemo.MainActivity.java
private void doParse() { try {/* w w w. j a v a 2 s . co m*/ String apkFile = Environment.getExternalStorageDirectory() + "/ApkParser/weixin.apk"; Parser parser = new Parser(getApplicationContext(), apkFile); // PackageManager pm = getPackageManager(); // PackageInfo info = pm.getPackageArchiveInfo(apkFile, // PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); parser.collectCertificates(0); PackageInfo apkPackageInfo = parser .getPackageInfo(PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); String packageName = parser.getPackageName(); List<ActivityInfo> activityInfos = parser.getActivities(); List<ServiceInfo> serviceInfos = parser.getServices(); List<ActivityInfo> receiverInfos = parser.getReceivers(); List<ProviderInfo> providerInfos = parser.getProviders(); List<InstrumentationInfo> instrumentationInfos = parser.getInstrumentations(); List<PermissionInfo> permissionInfos = parser.getPermissions(); List<String> requestPermissions = parser.getRequestedPermissions(); List<ParentItem> parents = new ArrayList<>(); parents.add(new PackageParent(packageName)); parents.add(new ActivityParent(activityInfos)); parents.add(new ServiceParent(serviceInfos)); parents.add(new ReceiverParent(receiverInfos)); parents.add(new ProviderParent(providerInfos)); parents.add(new InstrumentationParent(instrumentationInfos)); parents.add(new CustomPermissionParent(permissionInfos)); parents.add(new RequestPermissionParent(requestPermissions)); mExpandableListView.setAdapter(new ListAdapter(this, parents)); } catch (Exception e) { e.printStackTrace(); } }
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); }//from ww w. j a v a 2 s. c o m 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:facebook.hellofriends.app.MyFaceBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {//from www . java 2 s.c o 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.imagine.BaseActivity.java
int sigHash() { try {/* ww w . ja va 2s.c o m*/ Signature[] sig = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures; //Log.i(logTag, "sig hash " + sig[0].hashCode()); return sig[0].hashCode(); } catch (PackageManager.NameNotFoundException e) { return 0; } }