some errors in android(sdk)???

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

some errors in android(sdk)???

Postby smalltalk » Wed Mar 12, 2008 2:17 pm

Hi +- :)
I want to ask you 2 question.
First question:
I want to build an encryption application in Android. I recognized in Android that has 2 useful library: javax.crypto, java.security. Are they from JDK of java? And if yes, they are from jdk 1.5 or jdk 1.6? On the other hand, when I run Cipher.getMaxAllowedKeyLength(“RC2”); but it always returns Integer max value with any argument (RC2 is only example). When I run in Java (NetBean Enviroment 5.5.1), Cipher.getMaxAllowedKeyLength(“RC2”) run ‘OK’ (return 128 with RC2). I don’t know what happened. I suppose virtual machine (dalvik) or SDK has some errors but not sure.Code below is ‘Ok’ for java(return 128) but not OK for android (return int max value).
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import java.security.NoSuchAlgorithmException;
  2. import javax.crypto.Cipher;
  3. import javax.crypto.NoSuchPaddingException;
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.widget.TextView;
  7.  
  8. public class Security extends Activity {
  9.     /** Called when the activity is first created. */
  10.         String maxkeysize= "";
  11.     @Override
  12.    
  13.     public void onCreate(Bundle icicle) {
  14.         super.onCreate(icicle);
  15.         TextView t = new TextView(this);
  16.         initData();
  17.         t.setText(maxkeysize);
  18.         setContentView(t);
  19.     }
  20.     void initData()
  21.     {
  22.         try {
  23.                 int imaxkeysize = Cipher.getMaxAllowedKeyLength("RC2");
  24.                 maxkeysize = "Size is: " + imaxkeysize;
  25.                 maxkeysize +="n";
  26.                 maxkeysize += Integer.MAX_VALUE;
  27.                 Cipher des;
  28.                 try {
  29.                         des = Cipher.getInstance("DES");
  30.                         maxkeysize +=des.getAlgorithm();
  31.                         maxkeysize += " " + des.getBlockSize();
  32.                 } catch (NoSuchPaddingException e) {
  33.                 // TODO Auto-generated catch block
  34.                         e.printStackTrace();
  35.                 }
  36.                        
  37.         } catch (NoSuchAlgorithmException e) {
  38.                 // TODO Auto-generated catch block
  39.                 maxkeysize = e.toString();
  40.         }
  41.        
  42.     }
  43. }
  44.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Second question
Has Android a mechanism plugin. In android, for example, has contact application. Can I ‘add’ a function as plugin for contact application???

Please reply me fast (I'm really hurry) :(
Thank you very much :?
smalltalk
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Feb 12, 2008 3:34 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 6 guests