Zxing library
compile 'com.google.zxing:core:3.2.0'
compile 'com.journeyapps:zxing-android-embedded:3.0.0@aar'
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_fridge,container,false);
context=container.getContext();
IntentIntegrator.forSupportFragment(FragmentFridge.this).initiateScan();
return view;
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
Log.v(TAG,"onActivityResult"+resultCode);
if(resultCode == Activity.RESULT_OK) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
Log.v(TAG, "result.getContents() == "+scanResult.getContents());
Toast.makeText(context,scanResult.getContents(),Toast.LENGTH_SHORT).show();
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
참고 자료
QRcode
naver and Zxing
Lotto조회https://everyshare.tistory.com/51
StackOverflow