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
* @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.");
}
} 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.");
}
}
}
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)) {