QrCardParsing
Android Libraries to parsing and generate MeCard, VCard, VEvent and WifiCard content string.
Requirements
The library requires Android API Level 9+.
Import
in build.gradle
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile 'it.auron:mecard-parser:1.1.0'
}
How to use
Generate MeCard content
MeCard meCard =new MeCard();
meCard.setName("Luca");
meCard.setSurname("Rurio");
meCard.setDate("1989-07-19");
meCard.setEmail("[email protected]");
meCard.setNote("generate MeCard string content!");
meCard.addTelephone("+39 3486454313");
meCard.addTelephone("+39 3476512321");
meCard.setUrl("https://github.com/RurioLuca");
meCard.setAddress("via del corso , Rome , Italy");
meCard.setOrg("your company");
String meCardContent=meCard.buildString();
//sample using QrGen to generate QrCode bitmap
imageView.setImageBitmap(QRCode.from(meCardcontent).bitmap());
Parsing MeCard content
String meCardString = "MECARD:N:Rurio,Luca;TEL:+39 3486454313;EMAIL:[email protected];URL:https://github.com/RurioLuca;NOTE:generate MeCard!;BDAY:1989-07-19;ADR:via del corso , Rome , Italy;ORG:your company;";
MeCard meCard = MeCardParser.parse(meCardString);
String name = meCard.getName();
//output :Luca
String name = meCard.getEmail();
//output :[email protected]
meCard.setDate("1989-07-19");
String meCardContent=meCard.buildString();
//sample using QrGen to generate QrCode bitmap
imageView.setImageBitmap(QRCode.from(meCardcontent).bitmap());
Generate VCard content
VCard vCard=new VCard();
vCard.setName("Luca");
vCard.setAddress("via del corso");
vCard.setCompany("freelancer");
vCard.addEmail("[email protected]");
vCard.addTelephone("+39 3486454314");
vCard.setFormattedName("Rurio Luca");
vCard.setTitle("Developer");
vCard.setUrl("https://github.com/RurioLuca/MeCardParsing/");
imageView.setImageBitmap(QRCode.from(vCard.buildString()).bitmap());
Parsing VCard content
String vCardString = "BEGIN:VCARD\n" +
"N:Luca\n" +
"FN:Rurio Luca\n" +
"ORG:freelancer\n" +
"TITLE:Developer\n" +
"EMAIL:[email protected]\n" +
"URL:https://yoursite.com\n" +
"END:VCARD";
VCard vCard = VCardParser.parse(vCardString);
vCard.setNote("vCard generate and modified!");
vCard.addTelephone("+39 3486454314");
String vCardcontent = vCard.buildString();
//sample generate bitmap using QrGen
imageView.setImageBitmap(QRCode.from(vCardcontent).bitmap());
Generate Wifi content
WifiCard wifiCard = new WifiCard();
wifiCard.setSid("Vodafone Wifi32341");
wifiCard.setPassword("administrator");
wifiCard.setType("WPA");
//sample generate Qr code using Qrgen
imageView.setImageBitmap(QRCode.from(wifiCard.buildString()).bitmap());
Parsing Wifi content
String wifiString = "WIFI:S:Vodafone Wifi32341;T:WPA;P:administrator;;";
WifiCard wifiCard = WifiCardParser.parse(wifiString);
wifiCard.setPassword("administrator2016");
String wifiCardcontent = wifiCard.buildString();
//sample generate Qr code using Qrgen
imageView.setImageBitmap(QRCode.from(wifiCardcontent).bitmap());
Generate VEvent content
VEvent vEvent = new VEvent();
vEvent.Summary("Google IO");
vEvent.Location("Shoreline Amphitheatre Mountain View, California");
vEvent.Url("www.sample.com");
vEvent.setDtStart("20170611T130000Z");
vEvent.setDtEnd("20170611T153400Z");
//sample generate Qr code using Qrgen
imageView.setImageBitmap(QRCode.from(vEvent.buildString()).bitmap());
Parsing VEvent content
String vEventString = "BEGIN:VEVENT\n" +
"SUMMARY:Google IO\n" +
"LOCATION:Shoreline Amphitheatre Mountain View, California\n" +
"DTSTART:20170611T130000Z\n" +
"DTEND:20170611T153400Z\n" +
"END:VEVENT";
VEvent vEvent = VEventParser.parse(vEventString);
vEvent.setSummary("Google I/O");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(VEventCostant.DATE_FORMAT);
try {
Calendar calendar = Calendar.getInstance();
calendar.setTime(simpleDateFormat.parse(vEvent.getDtEnd()));
calendar.set(Calendar.DAY_OF_MONTH, 12);
calendar.set(Calendar.HOUR_OF_DAY, 14);
calendar.set(Calendar.MINUTE, 00);
vEvent.setDtEnd(simpleDateFormat.format(calendar.getTime()));
}
catch (ParseException e) {
e.printStackTrace();
}
String vEventcontent = vEvent.buildString();
//sample generate Qr code using Qrgen
imageView.setImageBitmap(QRCode.from(vEventcontent).bitmap());
Developed By
Rurio Luca- [email protected]
App using QrCardParsing
send me your apps! [email protected]
License
The MIT License (MIT)
Copyright (c) 2016 Rurio Luca
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.