Why i get result.get(CaptureResult.CONTROL_AF_STATE); == INACTIVE? - java
I work with camera2API on Samsung S5 and if i try get state of focus i get value 0 which is equals to CaptureResult.CONTROL_AF_STATE_INACTIVE...
There is snip of code :
private void process(CaptureResult result) {
switch (mState) {
case CameraHelper.STATE_PREVIEW: {
// We have nothing to do when the camera preview is working normally.
here i get ---> Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
if (CaptureResult.CONTROL_AF_TRIGGER_START == afState) {
if (areWeFocused) {
Log.e("---!!! HERE !!!--- :", String.valueOf(areWeFocused));
}else {
}
}
if (CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED == afState) {
areWeFocused = true;
} else {
areWeFocused = false;
}
break;
}
But i also tried to test it on my Meizu MX5 and i get 1 - CaptureResult.CONTROL_AF_TRIGGER_START or 2 - CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED
Question is : what is the difference in my code? Why do i get 0 in one case and 1 or 2 in another?
I know this is an old question, but i just ran into the same issue. Read through the Android docs about ControlAfState (AF = Auto Focus for those who are unaware, like I was). If AutoFocus Mode (afMode) is set to AF_MODE_OFF you will get the ControlAfState of Inactive.
Android CaptureResult.CONTROL_AF_STATE
Related
How i can update this Setlist of users?
I need some help guys. I'm making a chat who read an XML each 10 sec aprox (yeah the database is the XML, congrats my teacher, we can't change database format xDD) So on, my question now i create the function, replace the messages is easy, if the xml messages are more than RAM one, then i clear the ram and then add all messages again, but i can't do that to users, i don't know why but i think equals or something is broken(? i don't know pls help me my brain is about to break! if (temp.getList().size() > roomList.getList().size()) { for (Room room_xml : temp.getList()) { if (roomList.addRoom(room_xml)) { System.out.println("A room was loaded"); } } } else { for (Room room_xml : temp.getList()) { for (Room room_ram : roomList.getList()) { if (room_ram.equals(room_xml)) { if (room_ram.getMessageList().size() < room_xml.getMessageList().size()) { room_ram.getMessageList().clear(); room_ram.getMessageList().addAll(room_xml.getMessageList()); } Set<User> us_xml = room_xml.getUserList(); for(User u_xml: us_xml){ for(User u_ram: room_ram.getUserList()){ if(room_ram.getUserList().add(u_xml)){ System.out.println("User was added(?"); } } } /*for (User u_xml : room_xml.getUserList()) { if(room_ram.getUserList().add(u_xml)){ System.out.println("User was added(?"); }else{ break; } }*/ I share my proyect on github if u need more info about that : https://github.com/Varo95/ChaTerra This code is on RoomListDAO.java PD: I put print but i use javafx xd I got another idea, like declaring actual_user on roomdao and check on xml is on the list to add one....but doesn't seems to work :(
I already resolve it, thanks any way, i already do this and seems to work: RoomList temp = load(); if (temp.getList().size() > roomList.getList().size()) { for (Room room_xml : temp.getList()) { if (roomList.addRoom(room_xml)) { System.out.println("Room was loaded on RAM"); } } } else { for (Room room_xml : temp.getList()) { for (Room room_ram : roomList.getList()) { if (room_ram.equals(room_xml)) { if (room_ram.getMessageList().size() < room_xml.getMessageList().size()) { room_ram.getMessageList().clear(); room_ram.getMessageList().addAll(room_xml.getMessageList()); } room_ram.getUserList().clear(); room_ram.getUserList().addAll(room_xml.getUserList()); } break; } } } saveFile(roomList); And saving it too when user left the room or join but i need to make some little fixes more hahahaha well now i feel good with myself
Getting NMEA DATA in android
The current issue that I'm getting is that the OnNmeaListener is not returning the correct data from the NMEA using the GpsStatus.Listener therefore I tried the GNSS Status for the peace of mind, it ended up returning gibberish data , so I had to revert back to GpsStatus Listener. I also prior to using OnNmeaListener tried GpsStatus.NmeaListner and when used tried to add it to the GpsStatus Listener it would show up as an error and suggested that i typecast it to OnNmeaListener, when this is done and the app is built and all and then executed from the app, it would crash and then not work at all, and this is why i shifted to OnNmeaListener in the first place. Now to its credit the OnNmeaListener works just fine and doesn't crash at all, but the data it gives out is not at all accurate, I thought maybe this might have to be some sort of fault/error on the device side, I then proceeded to test it on two devices with different API levels of 25 and 28, On the the 25 Level device it just did not give half of the data whereas on the 28 level device the data is full but not accurate and correct. This is the method that I'm currently using: OnNmeaMessageListener nmeaMessageListener = new OnNmeaMessageListener () { #Override public void onNmeaMessage(String nmea , long timestamp) { if (trackStarted == true && trackPaused == false) { if (nmea.startsWith ( "$GPGGA" ) || nmea.startsWith ( "$GPRMC" )) { //Log.d("TrackManagerService","NMEA:" + nmea); try { // out.write(nmea.getBytes()); if (continuesMode) { dataOut.write ( nmea.getBytes () ); bufferedNMEALines++; if (bufferedNMEALines >= 10) { flushContinuesTrack (); //dataOut.reset(); bufferedNMEALines = 0; } } else { outCompressed.write ( nmea.getBytes () ); } // Log.d("TrackManagerService","NMEA:" + nmea); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace (); } if (nmea.startsWith ( "$GPGGA" )) { String[] nmeaSplit = nmea.split ( "," ); if (nmeaSplit.length > 10) { if (nmeaSplit[9].length () > 0) { try { mslAltitude = Float.parseFloat ( nmeaSplit[9] ); } catch (NumberFormatException ex) { mslAltitude = 0; } } else { mslAltitude = 0.0f; } } } } //if (markStarted && hasFix() && nmea.startsWith("$GPGGA")) { if (markStarted && hasFix () && nmea.startsWith ( "$GPRMC" )) { markProgress++; trackListener.onMarkProgress ( markProgress ); if (markProgress >= markMax) { stopMark (); } } } } }; And this is the output it gives when called: $Start,082719,260220; $GPGGA,082721.42,2654.2979,N,08056.6065,E,0,100.000,0.000,M,M,0,*44 $GPRMC,082721.42,V,2654.2979,N,08056.6065,E,0.000,0.000,260220,E,N*01 $GPGGA,082722.41,2654.2979,N,08056.6065,E,0,100.000,0.000,M,M,0,*44 $GPRMC,082722.41,V,2654.2979,N,08056.6065,E,0.000,0.000,260220,E,N*01 $End,082802,260220; $Start,082804,260220; $GPGGA,082837.42,2654.2979,N,08056.6065,E,0,100.000,0.000,M,M,0,*4C $GPRMC,082837.42,V,2654.2979,N,08056.6065,E,0.000,0.000,260220,E,N*09 $GPGGA,082838.42,2654.2979,N,08056.6065,E,0,100.000,0.000,M,M,0,*43 $GPGGA,082840.42,2654.2979,N,08056.6065,E,0,100.000,0.000,M,M,0,*4C $End,082841,260220; $Start,082921,260220; $GPGGA,082923.40,2654.2982,N,08056.6059,E,0,100.000,0.000,M,M,0,*41 $GPRMC,082923.40,V,2654.2982,N,08056.6059,E,0.000,0.000,260220,E,N*04 $GPGGA,082924.40,2654.2982,N,08056.6059,E,0,100.000,0.000,M,M,0,*46 $GPRMC,082945.40,V,2654.2982,N,08056.6059,E,0.000,0.000,260220,E,N*04 $End,082945,260220; And this is the output when called using GNSS listener: $Start,080450,260220;������������������������������������������������������������������������������������������������������������������������������������������������������������������ Any Sort of way to make this works? [EDIT] This is the response from an iOS device, which was accepted by the sever: $Start,150403,250220; $GPGGA,150403.69,2654.29986954,N,8056.60312653,E,1,00,0.0,0.0,0,0.0,0,0.0,0000*42; $GPRMC,150743.99,A,2654.29986954,N,8056.60260391,E,0.0,0.0,250220,0.0,E,A*5; $GPRMC,150844.26,A,2654.29986954,N,8056.60260391,E,0.0,0.0,250220,0.0,E,A*9; $GPRMC,150937.91,A,2654.30012894,N,8056.60312653,E,0.0,0.0,250220,0.0,E,A*e; $GPGGA,150945.04,2654.30429840,N,8056.60781097,E,1,00,0.0,0.0,0,0.0,0000*42; $GPRMC,150952.01,A,2654.29921722,N,8056.60364532,E,0.0,0.0,250220,0.0,E,A*2; $End,150953,250220; $GPGGA,150953.00,2654.29921722,N,8056.60364532,E,1,00,0.0,0.0,0,0.0,0000*42; $GPRMC,150953.00,A,2654.29921722,N,8056.60364532,E,0.0,0.0,250220,0.0,E,A*2; Now, I DO NOT have the faintest idea how this works on an iOS device,(a Senior of mine worked on that and gave me this data) but somehow it worked on that and when the same logic was implemented on Android and the data was uploaded to the server it wouldn't accept it, whereas when the iOS data was manipulated in any sort of way ( removing lines, addlines, removing semi-colons, commas,etc.) it would somehow still work.
Can the accessibility "Magnification Gesture" be detected on Android?
I've got a game app and it requires repeated tapping. Some players are complaining that it doesn't work when they have the "triple tap to zoom" accessibility gesture enabled on their device. Web search showed me that it can't be disabled within my game, but can it be detected? At least then I can explain to users how to turn it off while playing. I'm not sure which android API I could use to check this setting. I'm not a native android developer, I work in Unity and Google isn't turning up anything.
Thanks to zcui93, I was able to test for this setting using the following Java: Settings.Secure.getInt( context.getContentResolver(), "accessibility_display_magnification_enabled" ); ...just check the return value: 1 = enabled, 0 = disabled Here's the code to do it in a Unity C# Script: public static bool CheckForSystemZoomEnabled() { #if UNITY_ANDROID try { using(AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver"); using(AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure")) { int val = clsSecure.CallStatic<int>("getInt", objResolver, "accessibility_display_magnification_enabled"); return val != 0; } } } catch(System.Exception) { } #endif return false; }
Javascript function Wicket test
I have an ajaxEditableLabelWithIcon which is a ajaxEditableLabel with a modified HTML that contain an icon. When the user click this icon, the editor field become editable and when he click again, the content is saved. We did that using JQuery : function editOrSubmit(element){ panel = element.parentElement; label = panel.children[0]; if(panel.find){ e = $.Event('keypress'); e.which = 13; // Enter key label.trigger(e); //submit the FormTester } else{ label.click(); //Wich make the label editable } } Now, I want to test it using JUnit. Since I can't directly click on the icon, I tried to create a javascript shortcut to the function, and then create a Robot to trigger the KeyPressed events : // defining flags var isCtrl = false; var isShift = false; $(document).ready(function() { // action on key up $(document).keyup(function(e) { if(e.which == 17) { isCtrl = false; } if(e.which == 16) { isShift = false; } }); // action on key down $(document).keydown(function(e) { if(e.which == 17) { isCtrl = true; } if(e.which == 16) { isShift = true; } // En cas d'appui sur ctrl+Shift+F9 en même temps, la méthode editOrSubmit est appelée if(e.which == 120 && isCtrl && isShift) { var icon = document.getElementById("icon"); editOrSubmit(icon); } }); }); It work well in a browser, but inside the test nothing happen ? Do you know why ?
unfortunately Wicket and JUnit cannot test JavaScript code but just Java code. However, Wicket itself uses Maven and frontend-maven-plugin to run QUnit tests via Maven. You can take a look at Wicket code inside testing/wicket-js-tests (https://github.com/apache/wicket/tree/master/testing/wicket-js-tests) to see how this is done by Wicket and you can copy the code you need to run your tests.
I want to log out my application after browser close in every browser?
I am calling this code by this window.onbeforeunload=HandleOnClose; This is working fine in IE but not in other browsers. This code is specific for IE but this is not working in other browsers. How can we detect close event of browser in all the browser ? function ConfirmClose() { if (isIE7Min) //To check for IE Version 7.0 and above { var n = window.event.screenX - window.screenLeft; var b = n > document.documentElement.scrollWidth-20; if ((b && window.event.clientY < 0) || window.event.altKey) { if (!self.closed) { refresh = true; } } } else //IE Version 6.0 and below { if (event.clientY < 0 && event.clientX < 0) { if (!self.closed) { refresh = true; } } } } /*Function for onunload*/ function HandleOnClose() { ConfirmClose(); if (isIE7Min) { if ((window.event.clientX > 0 && window.event.clientY < 0) || window.event.altKey) { if (refresh == true) { window.open("/DealPricingJavaUAT/DealPricingJsp/Home/logout.jsf"); //Code That redirects to the Session Invalidation Page } } } else { if (event.clientY < 0 && event.clientX < 0 || window.event.altKey) { if (refresh == false) { window.open("/DealPricingJavaUAT/DealPricingJsp/Home/logout.jsf"); // Code That redirects to the Session Invalidation Page } } } }
I don't think it is possible to always log user out. If there is a crash on user's web browser, the client-side code will never get executed. Some web browsers shutdown itself very fast and don't wait to execute the client-side code. You should find an alternative solution, like logging out on server side if user is not active for certain period of time.
Its not possible to detect when the user closes the browser. If you are using java and using cookies to check if the user is logged-in, you can do cookie.setMaxAge(-1). This will make sure that cookies are deleted when browser closes.