Downloaded Xamarin Camera2Basic project
Initially all works correctly as it's begin tested in Visual Studio 2017 emulator.
Commented out code inside "CameraCaptureStillPictureSessionCallback.cs" as shown below to allow the still image captured to be displayed on the emulator screen after clicking the "Take Picture" button:
public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
//Owner.ShowToast("Saved: " + Owner.mFile);
//Log.Debug(TAG, Owner.mFile.ToString());
//Owner.UnlockFocus();
}
Clicking the "Take Picture" button hides itself, and shows another button labeled "Retake Picture" on the screen (which I added after the fact and the code is located in the Camera2BasicFragment.cs file, but the code is inconsequential to the issue).
Clicking the now visible "Retake Picture" button does the following:
Hides itself
Shows the "Take Picture" button
Calls UnlockFocus()
UnlockFocus() allows the camera's stream to display continuously on the screen instead of the still image captured previously.
Now, when I click the "Take Picture" button again (to attempt to capture a new still image), the app crashes.
Visual studio does not provide any meaningful error messages. The closest useful bit of information are the error messages displayed int the Device Log:
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 BufferQueueProducer [ImageReader-640x480f100m2-6987-0] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count
07-26 23:29:07.174 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 RequestThread-0 Hit timeout for jpeg callback!
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 Legacy-CameraDevice-JNI LegacyCameraDevice_nativeProduceFrame: Error while producing frame Function not implemented (-38).
I'm not sure what to make of these errors, or which settings/code to change to allow the "Retake Picture" functionality to work without crashing the app.
Any suggestions?
EDIT 1:
Per request, where is a link to the project as I currently have it.
https://drive.google.com/file/d/0B7OSuA_ybXcFb081T210UlQzZkE/view?usp=sharing
Here is some other seemingly pertinent information:
This code was run using:
a. Windows 10 Pro, Visual Studio 2017 Community, Android Emulator
For Visual Studio, Hyper-v Virtual Manager, Android 6.0
(Marshamallow SDK 23), Tablet sized template
b. 2013 Macbook Pro, Visual Studio For Mac (latest version), default
emaulator, Android 6.0 (Marshmallow SDK 23), Tablet sized template.
The failure to take snapshot after second "LockFocus" call is observed in both environments.
The Mac made it easier to find some more meaninful errors:
a. The error I saw happened on method "produceFrame" inside
LegacyCameraDevice.java
I've the problem with this demo also, The real problem behind this is about the IOnImageAvailableListener, it will not trigger the OnImageAvailable method to save the picture...
After read the code, i found out that the demo is broken, it missing some piece.
In the Camera2BasicFragment.cs, in the OnCreateMethod, you will need to add this line
mCaptureCallback = new CameraCaptureListener() { Owner = this};
The entire method should look like this:
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
mStateCallback = new CameraStateListener() { owner = this };
mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
// fill ORIENTATIONS list
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
}
The interesting thing is, if you run this on emulator, nothing will happened, because in the CameraCaptureListener.cs file, this will always return 0, not ControlAFState.FocusedLocked or ControlAFState.InActivate
Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
Event if i hack the If method to be able to run jump into next step, the method OnImageAvaiable of ImageAvailableListener.cs will never be triggered by emulator. But if i run on the real device, it ran fine ?!
So the fix is:
1. Add the code above like i explained on the onCreate function.
2. Don't use emulator to run Camera2, it's buggy.
Hope it help :)
If you are still interested; IOnImageAvailableListener not trigger OnImageAvailable method in Visual Studio Emulator For Android.
Code is correct but Visual Studio Emulator For Android have a bug. I hope they fix it as soon as possible. On the other hand you can try your code in Xamarin by using Android Studio Emulator without any bug. It is easy and you dont need to know anything about Java or Android Studio Just follow the below steps
Install Android Studio with virtual device
Close Hper-v on your pc (windows -> control panel -> programs -> programs and features -> Turn windows features on or off)
Open android studio -> Tools -> Avd Manager -> Create Virtual Device
Visual studio detect the virtual device just use it on Visual Studio Xamarin
hope it help
Related
I'm having issue of missing signout button from the header toolbar in android devices. In simulator and apple device I do see the signout button but not on android tablet/phone. This wasn't the case before 3-4 days. Is there any change in the android build server that causing this issue. This is happening when more than one control in the toolbar. if the toolbar has one control to the right then it displays without any issue. Please let me know if anyone else have same issue.
Android Simulator Screenshot
Android Tablet Screenshot
public static void addSignout(Form f) {
f.getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_LOCK, 6.5f, e -> {
Server.instance.logout();
new LoginForm().show();
});
}
I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.
Yesterday (10/19/2015 06:00 PM), the ARC Welder app begin to not start apps.
For some reason, now, when I click "TEST", nothing happens on Windows 10, I tested on MAC/Windows 7 also, and works fine.
Chrome
Versão 46.0.2490.71 (64-bit)
ARC Welder
46.5021.478.14
Update
This is the error shown on console.
Uncaught (in promise) TypeError: Cannot read property 'angle' of
undefined
at $jscomp.scope.Plugin.computeLayout_ (chrome-extension://joabdphlghkbahegchlcmhbaaijcgghj/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_index.min.js:125:302)
at $jscomp.scope.Plugin.doLayout_ (chrome-extension://joabdphlghkbahegchlcmhbaaijcgghj/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_index.min.js:122:383)
at $jscomp.scope.Plugin.initializeWindow_ (chrome-extension://joabdphlghkbahegchlcmhbaaijcgghj/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_index.min.js:98:175)
at null. (chrome-extension://joabdphlghkbahegchlcmhbaaijcgghj/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_index.min.js:95:238)
Workaround SOLUTION at bottom.
Ok so what I have so far is not a solution just information
The problem seems to be coming from the runtime part of the Arc Extension:
SEE-> https://chrome.google.com/webstore/detail/app-runtime-for-chrome-be/mfaihdlpglflfgpfjcifdjdjcckigekc
The problem is in the file plugin.js
// Let the CameraManager in Android know what the current orientation is
var message = {
namespace: 'pluginCameraManager',
command: 'screenRotation',
data: {
'angle': screen.orientation.angle
}
};
this.postMessage(message);
Cannot read property 'angle' of undefined at...
'angle': screen.orientation.angle
//for context
var a=Promise.all([this.createAppPlugin_(),window.arcparams.systemDirectoriesReady]);
//problem is initializeWindow_() fails
a.then(function(){this.initializeWindow_();
** WORK AROUND SOLUTION**
This may cause more bugs, I don't know, do it at own risk.
Open the file:
%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\mfaihdlpglflfgpfjcifdjdjcckigekc\46.5021.478.18_0\gen_index.min.js
ie
extension://joabdphlghkbahegchlcmhbaaijcgghj/_modules/mfaihdlpglflfgpfjcifdjdjcckigekc/gen_index.min.js:125:302)
So on line 125 at character 302 you should find the word 'angle' as in:
data:{angle:screen.orientation.angle}
change that to:
data:{angle:0}
0 is used,you can read about why -> Find screen angle when orientation is fixed in android
I'm getting a very weird error ever since I have "ported" the spritebatch code from Nokia's site. It runs well as a desktop applcation emulated by POWERVR. But on Android I only get a blank screen (in fact its black.) This happens if I just try to display a image, but it doesn't crash.
Here is where comes the weird part comes in: if i put glGeterror(); in the update function it works fine! (slowly, but displays everything fine) and geterror code returns 0. I have no idea what is going on or how to debug it, as I'm new to OpenGL but everything looks correct in the source. I spitted geterrors all around the code but without any clue. I've attached my project if you want to take a look. You will need Visual Studio + vsandroid to compile.
apparently the problem is not on the sprite batch, but in the java code. I replaced for another one that uses surface view and no longer im getting this esotheric behavior.
TL;DR: how do I remove support for touchscreen in the emulator, in the new ADT 21? Basically, I want to simulate a (dpad and qwerty)-only device. Details below.
Neither the new "Device Definitions" nor the "Android Virtual Devices" show a way to edit the hardware, as the old dialog is not available anymore.
Aware of that, I edited the virtual device config.ini file myself, before starting the emulator, to include the hw.touchscreen line. It had no effect, and this code:
Toast.makeText(getActivity(),
String.valueOf(getActivity().getPackageManager().hasSystemFeature("android.hardware.touchscreen")),
Toast.LENGTH_SHORT).show();
shows true. I suspected this has something to do with the new (to me) hw.device.name option, which is related to the new Device Definitions tab. And there is a devices.xml file, which includes a touchscreen definition (relevant lines):
<d:device>
<d:name>3.5 nHD</d:name>
<d:manufacturer>User</d:manufacturer>
<d:meta/>
<d:hardware>
<d:screen>
<d:screen-size>normal</d:screen-size>
<d:diagonal-length>3.50</d:diagonal-length>
<d:pixel-density>mdpi</d:pixel-density>
<d:screen-ratio>long</d:screen-ratio>
<d:dimensions>
<d:x-dimension>360</d:x-dimension>
<d:y-dimension>640</d:y-dimension>
</d:dimensions>
<d:xdpi>209.80</d:xdpi>
<d:ydpi>209.80</d:ydpi>
<d:touch>
<d:multitouch>jazz-hands</d:multitouch>
<d:mechanism>finger</d:mechanism>
<d:screen-type>capacitive</d:screen-type>
</d:touch>
</d:screen>
(...)
I've tried just removing the d:touch section. Still, no effect. Any ideas?