Logging vCard content received to help debug
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 22 Nov 2009 05:59:00 +0000 (05:59 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 22 Nov 2009 05:59:00 +0000 (05:59 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1117 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java

index 4e1d9fb..e1da5fa 100755 (executable)
@@ -42,6 +42,7 @@ import android.util.Log;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.Charset;
 
 /**
  * This class does the work of decoding the user's request and extracting all the data
@@ -50,13 +51,16 @@ import java.io.InputStream;
  * @author dswitkin@google.com (Daniel Switkin)
  */
 final class QRCodeEncoder {
+
+  private static final String TAG = "QRCodeEncoder";
+
   private final Activity activity;
   private String contents;
   private String displayContents;
   private String title;
   private BarcodeFormat format;
 
-  public QRCodeEncoder(Activity activity, Intent intent) {
+  QRCodeEncoder(Activity activity, Intent intent) {
     this.activity = activity;
     if (intent == null) {
       throw new IllegalArgumentException("No valid data to encode.");
@@ -69,7 +73,7 @@ final class QRCodeEncoder {
       }
     } else if (action.equals(Intent.ACTION_SEND)) {
       if (!encodeContentsFromShareIntent(intent)) {
-      throw new IllegalArgumentException("No valid data to encode.");
+        throw new IllegalArgumentException("No valid data to encode.");
       }
     }
   }
@@ -142,7 +146,8 @@ final class QRCodeEncoder {
       int length = stream.available();
       byte[] vcard = new byte[length];
       stream.read(vcard, 0, length);
-      String vcardString = new String(vcard, "utf-8");
+      String vcardString = new String(vcard, Charset.forName("UTF-8"));
+      Log.d(TAG, "Encoding share intent content: " + vcardString);
       Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
       ParsedResult parsedResult = ResultParser.parseResult(result);
       if (!(parsedResult instanceof AddressBookParsedResult)) {