In Xamarin android QR scan using zxing is much easy as it requires only 3 lines of codes.
MobileBarcodeScanner.Initialize(Application);
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
var result = await scanner.Scan();
string qrCode = result.ToString();
But it always opens a default view with full screen even if I set it inside oncreate event or button click. What I really need is having qr scan in half screen instead of full screen. remaining othert half screen will be used to add few buttons.
If anyone knows how to do it please let me know I have spent more than 3-4 days to find the answer for this component. Also if there are any other useful library than zxing for qr scanning let me know.
Thanks,
Muthu
As #SushiHangover mentioned, use the ZXingScannerFragment to achieve this. Take a look at the sample here.
Related
I follow the following link's sample code
http://android.dronekit.io/first_app.html
and when I set API VehicleApi.getApi(this.drone).arm(true);
vehicleState.isFlying() automatically becomes true.
Can anybody tell me what this problem is?
What I need is:
1. take off, land
I read from some website that the dronekit-android does not support the mode changing. If so, how should I send the mavlink message to take off and land?
So far, I can sucessfully send the mavlink message to the PX4 board.
Thanks for replying.
Thank you for replying.
BR
SeanH
If you trace though some of the code in dronekit-android, you can see that isFlying is set here with the code below.
boolean isFlying = systemStatus == MAV_STATE.MAV_STATE_ACTIVE || ...;
MAV_STATE_ACTIVE, defined here states
System is active and might be already airborne. Motors are engaged.
So isFlying doesn't mean it's airborne but just that the motors are turned on. That occurs when you call VehicleApi.getApi(this.drone).arm(true); because you are literally arming the vehicle at that point.
For takeoff, you want to use the ControlApi. ControlApi.getApi(drone).takeOff(desired_altitude, listener) and for land you need to use VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_LAND, listener)
The sample code you're looking at is very old. I suggest you follow the sample app from github.
I have not tried android-dronekit before and I noticed that the src folder have not been updated for more than two years on github.
I advice you to use python-dronekit because there is a powerful library called pymavlink in python and used in python-dronekit. You can build hyper application if you want but first try to takeoff and land in python.
thanks for checking my question out!
I'm currently working on a project using Qt C++, which is designed to be multi-platform. I'm a bit of a newcoming to it, so I've been asked to set up the ability to take screenshots from within the menu structure, and I'm having issues with the Android version of the companion app.
As a quick overview, it's a bit of software that send the content of a host PC's screen to our app, and I've been able to take screenshots on the Windows version just fine, using QScreen and QPixmap, like so:
overlaywindow.cpp
{
QPixmap screenSnapData = screenGrab->currentBackground();
}
screenGrabber.cpp
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
}
Unfortunately, Android seems to reject QScreen, and with most suggestions from past Google searches suggesting the now-deprecated QPixmap::grab(), I've gotten a little stuck.
What luck I have had is within the code for the menu itself, and QWidget, but that isn't without issue, of course!
QFile doubleCheckFile("/storage/emulated/0/Pictures/Testing/checking.png");
doubleCheckFile.open(QIODevice::ReadWrite);
QPixmap checkingPixmap = QWidget::grab();
checkingPixmap.save(&doubleCheckFile);
doubleCheckFile.close();
This code does take a screenshot, but only of the button strip currently implemented, and not for the whole screen. I've also taken a 'screenshot' of just a white box with the screen's dimensions by using:
QDesktopWidget dw;
QWidget *screen=dw.screen();
QPixmap checkingPixmap = screen->grab();
Would anyone know of whether there was an alternative to using QScreen to take a screenshot in Android, or whether there's a specific way to get it working as compared to Windows? Or would QWidget be the right track? Any help's greatly appreciated!
as i can read in Qt doc : In your screenGrabber.cpp :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
replace with :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( 0 ); // as 0 is the id of main screen
If you want to take a screenshot of your own widget, you can use the method QWidget::render (Qt Doc):
QPixmap pixmap(widget->size());
widget->render(&pixmap);
If you want to take a screenshot of another app/widget than your app, you should use the Android API...
after carefully following this answer: How to integrate Zxing Barcode Scanner without installing the actual zxing app (cannot resolve symbol: .android.CaptureActivity)? by Liran Cohen
the scanner should not be opened in a separate activity (called via intent),
it should be shown just below a button (like logout).
I was able to detect/scan and get the decoded string of the barcode but the problem is the red line is missing, how to make the red line appear?
I extended the captureActivity to a activity I am using like readerActivity and override the handleDecode function to detect/scan and decode the qr image.
just want to know how to show the red line.
also tried changing the following code in the viewfinderview but still not working:
int middle = frame.width() /2 + frame.left;
under the onDraw() function
also tried calling the function:
viewfinderView.setWillNotDraw(false);
in the oncreate function of the captureActivity, the red line is still hidden.
You can take the code of Zxing on GitHub and add it to your project.
Look at these activity CaptureActivity for adding similar code to your activity.
I have started using Andengine, and after following some tutorials I'm starting to develope for myself.
Right now I have a a BaseGameActivity where I call one splashScene(working fine) and after that my MenuScene.
If i set a simple background (just color) it loads fine (all menu text are displayed), but when i try to set a repeating sprite as background, a black screen appears (no error show in logcat)
I'm using the example code for the background
super(BaseActivity.getSharedInstance().mCamera);
activity = BaseActivity.getSharedInstance();
RepeatingSpriteBackground mGrassBackground = new RepeatingSpriteBackground(mCamera.getWidth(), mCamera.getHeight(), activity.getTextureManager(), AssetBitmapTextureAtlasSource.create(activity.getAssets(), "images/menu/background.png"), activity.getVertexBufferObjectManager());
this.setBackground(mGrassBackground);
I placed this code in the MenuScene constructor.
Thanks in advance and sorry for my English
I just discover my problem.
The code was right the problem was in the image format, it has to be a power of two (it says that clearly in the source code comments)
Next time I will try to read carefully before asking
I'm trying to develop an App witch get 1d bar codes number using Zxing lib. I download the lib and I compiled it with ant. Them, I include the core.jar into my app source.
Now, I wan't to get the number of the bar code, and I use the following java code:
Intent barscan = new Intent("com.google.zxing.client.android.SCAN");
barscan.putExtra("SCAN_WIDTH", 300);
barscan.putExtra("SCAN_HEIGHT", 200);
barscan.putExtra("RESULT_DISPLAY_DURATION_MS", 3000L);
barscan.putExtra("PROMPT_MESSAGE", "Custom prompt to scan a product");
barscan.putExtra("SCAN_MODE", "ONE_D_MODE");
startActivityForResult(barscan, 0);
But with this code I have some problems:
I can't see the red line across the screen.
I want to scan the barcode and return, but that only happens with QR codes. With 1d bar codes nothing happen.
What is wrong?
Thank everyone for your time!
(I answered already on the mailing list.)
If you don't see a red line, then you are not using Barcode Scanner to handle the Intent. I don't know what app is handling it, but it's not something from here.
Use Intent.setPackage() to restrict to Barcode Scanner's package of com.google.zxing.client.android. Better yet, use the provided IntentIntegrator code.