Esempio n. 1
0
  public static String printKeyHash(Context context) {
    PackageInfo packageInfo;
    String key = null;
    try {
      // getting application package name, as defined in manifest
      String packageName = context.getPackageName();

      // Retriving package info
      packageInfo =
          context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);

      Debug.e("Package Name=" + context.getPackageName());

      for (Signature signature : packageInfo.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        key = new String(Base64.encode(md.digest(), 0));

        // String key = new String(Base64.encodeBytes(md.digest()));
        Debug.e("Key Hash=" + key);
      }
    } catch (PackageManager.NameNotFoundException e1) {
      Debug.e("Name not found" + e1.toString());
    } catch (NoSuchAlgorithmException e) {
      Debug.e("No such an algorithm" + e.toString());
    } catch (Exception e) {
      Debug.e("Exception" + e.toString());
    }

    return key;
  }
Esempio n. 2
0
  public static boolean checkForDirectory(Context context, String path) {
    File f = new File(Environment.getExternalStorageDirectory().getPath());
    f = new File(f, path);
    if (f.exists() == true && f.isDirectory() == true) {
      Debug.e(path + " already exists.");
      return true;
    }
    Debug.e(path + " doesnt exists. So trying to create");
    f.mkdirs();
    f.setExecutable(true);
    f.setReadable(true);
    f.setWritable(true);
    // initiate media scan and put the new things into the path array to
    // make the scanner aware of the location and the files you want to see
    MediaScannerConnection.scanFile(context, new String[] {f.toString()}, null, null);

    Boolean successs = (f.exists() && f.isDirectory());
    Debug.i("checking if it was successfully created. " + successs);
    return successs;
  }
  @Override
  public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);

    //    boolean multiline = (attribute.inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0;
    //    Log.d("ivan", "onStartInput "
    //       + "actionId=" + attribute.actionId + " "
    //       + "id=" + attribute.fieldId + " "
    //       + "name=" + attribute.fieldName + " "
    //       + "opt=" + Integer.toHexString(attribute.imeOptions) + " "
    //       + "inputType=" + Integer.toHexString(attribute.inputType) + " "
    //       + "priv=" + attribute.privateImeOptions
    //       + "multiline=" + multiline);

    try {
      String text = getText();
      remoteKeyboard.startTextEdit(text);
    } catch (RemoteException e) {
      Debug.e("failed communicating to HttpService", e);
    } catch (NullPointerException e) {
      Debug.e("remoteKeyboard is not connected yet", e);
    }
  }