Android Signature - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Signature class.

This code example shows how to use the following methods:toByteArray
 
    private ContentValues createConsumer(String packageName, long regId, Signature sig,
            boolean isPublic) {
        ContentValues value = new ContentValues();
        value.put(Consumers.PACKAGE_NAME, packageName);
        value.put(Consumers.SIGNATURE, sig.toByteArray());
        value.put(Consumers.IS_SERVICE_PUBLIC, isPublic);
        value.put(Consumers.IS_BANNED, false);
        value.put(Consumers.OWNS_CONSUMER_KEY, true);
        value.put(Consumers.REGISTRY_ID, regId);
        return value;
    } 
 
    private void standardInsert() { 
        long[] ids = new long[6];
        ids[0] = mDB.insert("registry", "", createReg("test1"));
        ids[1] = mDB.insert("registry", "", createReg("test2"));
        ids[2] = mDB.insert("registry", "", createRegAuth("test3"));
        ids[3] = mDB.insert("registry", "", createRegAuth("test4"));
        ids[4] = mDB.insert("registry", "", createRegAuth("test5"));

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        assertTrue(cur.moveToFirst());
        assertEquals(PACKAGE_UNDER_TEST, cur.getString(0));
        assertEquals(0, cur.getInt(1));
        assertEquals(1, cur.getInt(2));
        assertEquals(1, cur.getInt(3));
        assertEquals(new Signature(SIGNATURE_FOR_PACKAGE), new Signature(cur.getBlob(4)));
        cur.close();
    } 
 
    public void testShouldUpdateCorrectly() throws Exception { 
        setPackage(PACKAGE_UNDER_TEST);
        setSignature(SIGNATURE_FOR_PACKAGE);
 
        ContentValues value = new ContentValues();
        value.put(Registry.ACCESS_TOKEN_URL, "http://access");
        value.put(Registry.REQUEST_TOKEN_URL, "http://request");
        value.put(Registry.AUTHORIZE_URL, "http://authorize");
        value.put(Registry.CONSUMER_KEY, "key");
        value.put(Registry.CONSUMER_SECRET, "secret123");
        value.put(Registry.URL, "http://twitter.com");
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        public PackageInfo getPackageInfo(String packageName, int flags)
                throws NameNotFoundException { 
 
            PackageInfo info = new PackageInfo();
            info.signatures = new Signature[] {
                new Signature(testSignature)
            }; 
            return info;
        } 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toByteArray
    try { 
      md = MessageDigest.getInstance("SHA1");
    } catch (NoSuchAlgorithmException e) {
      return ""; 
    } 
    md.update(sig.toByteArray());
    return toHexString(md.digest());
  } 
 
  public static String getUserAgent(Context context) {
    PackageInfo pinfo;
    try { 
      pinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (NameNotFoundException e) {
      pinfo = null;
    } 
 
    final String versionName;
    final int versionCode;
    if (pinfo != null) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toByteArray
        } 
        return false; 
    } 
 
    private X509Certificate toX509Certificate(Signature signature) throws CertificateException {
        byte[] cert = signature.toByteArray();
        InputStream input = new ByteArrayInputStream(cert);
        return (X509Certificate)this.certificateFactory.generateCertificate(input);
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toByteArray
        try 
        { 
            final PackageManager manager = context.getPackageManager();
            final PackageInfo info = manager.getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
            final Signature signature = info.signatures[0];
            return signature.toByteArray();
        } 
        catch ( NameNotFoundException e )
        { 
            return null; 
        } 
    } 
 
    private static byte[] digestBytesByMD5(final byte[] message)
    { 
        try 
        { 
            final MessageDigest digest = MessageDigest.getInstance("MD5");
            return digest.digest(message);
        } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
         
        WaveRecipeAuthorization auth = new WaveRecipeAuthorization(recipeOne);
        Date now = new Date();
        ComponentName clientName = new ComponentName("edu.berkeley.waveapps.fitness", ".FitnessActivity");
        auth.setRecipeClientName(clientName);
        auth.setRecipeClientSignatures(new Signature[] { new Signature("theatihceadocdttheaotnhai") });
        auth.setAuthorizedDate(now);
        auth.setModifiedDate(now);
         
        // test the save 
        assertTrue(databaseHelper.insertOrUpdateAuthorization(auth));
         
        // We need a WaveService instance to test the load, which doesn't suit 
        // this test, so we just check that the appropriate table now contains 
        // a row 
        assertEquals(1, rowCountForTable(databaseHelper.RECIPE_AUTH_TABLE_NAME));
         
        // test saving a revoked auth 
        Date later = new Date();
        auth.setRevokedDate(later);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android Signature Questions & Answers:

See Code Examples for Android Signature Methods: