Comments (6)
Still now no solution? :-(
from mobilevisionbarcodescanner.
@Bekakk Make sure you can camera permission granted for marshmallow devices. This should work.
from mobilevisionbarcodescanner.
@KingsMentor Even I grant it first time it does not work.
if(!hasPermissions(getContext(), PERMISSIONS)) {
ActivityCompat.requestPermissions(getActivity(), PERMISSIONS, CAMERA_PERMISSION_REQUEST_CODE);
} else {
barcodeCapture = (BarcodeCapture) getChildFragmentManager().findFragmentById(barcode);
barcodeCapture.setRetrieval(this);
}
from mobilevisionbarcodescanner.
@freebumba27 . Thanks for pointing this out. The problem is the xml has already been inflated and if the permission has not been granted, the app wouldn't be able to use the camera. Here is a quick fix:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_blur_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/mainLayout"
layout="@layout/toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/mainLayout"
android:background="#000"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="50dp">
<LinearLayout
android:id="@+id/cam_layout"
android:layout_width="300dp"
android:layout_height="300dp"
android:orientation="vertical"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp"
android:text="Align the QR Code/bar code within the frame to scan"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>
Notice that the barcode fragment in not in this xml.
I moved it to a seperated xml file : cam_layout.xml
and inflate it only when the permission has been granted.
Achieved that with this snippet:
View camView = LayoutInflater.from(this).inflate(R.layout.cam_layout, null, false);
((LinearLayout) findViewById(R.id.cam_layout)).addView(camView);
barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.barcode);
barcodeCapture.setRetrieval(this);
and here is cam_layout.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/barcode"
android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture"
android:layout_width="300dp"
android:layout_height="300dp"
app:gvb_auto_focus="true"
app:gvb_code_format="all_format"
app:gvb_flash="false" />
A more usable update will be pushed but this should work for you.
from mobilevisionbarcodescanner.
@freebumba27 does this works for you ?
from mobilevisionbarcodescanner.
Yes it worked perfectly. I will suggest you to make the camera full screen. I have tested the app in S7 edge it's taking back area at the bottom of the screen. I think it's duo to resolution. If you can fix this part and update the dependency then this one of the best Lib based on MobileVison
from mobilevisionbarcodescanner.
Related Issues (20)
- 409 error when downloading dependency from https://repo.jfrog.org/artifactory/libs-release-bintray/com/google/android/gms/play-services-basement-license/11.4.2/play-services-basement-license-11.4.2.pom?referrer
- Camera2 implementation.
- The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[11.0.4,11.0.4], [15.0.1,15.0.1]], but resolves to 15.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. HOT 4
- QR Code scanner is not Retrieval HOT 2
- update google play services version to latest HOT 1
- RxPermission Library version update
- is there a way to turn on/off flash without "refresh"?
- Disable auto requesting camera permission
- How can I make the fragment of quickstart guide fills the entire screen? HOT 3
- Dependency posted not working but this does
- [Feature Request] Support for androidx HOT 2
- can you please setZoom function to set zoom
- I have layout in a fragment. The App is crashing with the error log NullException cannot cast to BarcosdeCapture. For activity is working fine but for fragment it is crashing HOT 1
- Got conflit when try to add gms library HOT 1
- Unable to destroy activity null pointer exception at barcodecapture.ondestroy HOT 8
- I can't detect and track more than 3 QR Codes at the same time?
- This error log showing continuously and nonstop when I run in Emulator (Pixel 2) but Not happen in real devices.
- Want Solution On This ASAP HOT 2
- Camera Preview continues to stretch
- Rx permissions2 prevents building app when jcenter() is removed to add mavenCentral() repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobilevisionbarcodescanner.