UI Orientation Change-Make it independent for rotation - android-layout

I have a one condition. There is a SDK in my Project.who change activity orientation when it requires the performing an operation. But after its operation i have to set activity orientation according to the device orientation.
I used following method to set screen orientation back to previous orientation. But when i set it. Next time if i rotate my device my activity is not changing orientation according to the device.
Can anyone suggest me the proper solution to make my activity flexible again. Or solving this situation. Thanks In advance.
if(this.getResources().getConfiguration().orientation !=Configuration.ORIENTATION_PORTRAIT)
{
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

When device rotates the your activity will take take it's orientation according to the device but if set it's orientation then it will not change with device orientation.
refer this blog:
http://android-developers.blogspot.com/2009/02/faster-screen-orientation-change.html

Related

Wrong TileMap coordinates on zoom with InputEventScreenTouch

The goal is to enable the player to drow the patch for the character.
So I start with simple think, set value for cell(0, 0) in tilemap
and replace the value when the user clicks on it
and it works as expected.
But when I change the camera zoom and try it again it set value in another cell:
I was trying to multiple/divide the click position by the zoom value but it also not resolve the problem
Can anyone give me the hint on how should I handle that?
repo: Github
Once you zoom, the coordinates you get from the input event (screen coordinates) do not match the world.
If you have an input event, the recommended way to do this is with make_input_local:
tilemap.world_to_map(tilemap.make_input_local(event).position)
However, if you don't, but you have screen coordinates, you can do this:
var transform = tilemap.get_canvas_transform() * tilemap.get_global_transform()
tilemap.world_to_map(transform.affine_inverse() * screen_coordinates)

HandMotion Animation doesnt disable after plane has been discovered (ARCore)

I am using plane discovery in the augmented image sceneform example. So my new session configuration is like this in the AugmentedImageFragment -
getPlaneDiscoveryController().show();
getPlaneDiscoveryController().setInstructionView(null); //default handMotion animation appears
getArSceneView().getPlaneRenderer().setEnabled(true);
But when a plane is discovered the HandMotion animation still persist. I confirmed if the planes are being detected, and they are. Not sure why the animation stays. Is there any way to explicitly disable the animation in code ?

orientation changes in a NativeActivity

I have got a problem handling orientation changes from a nativeactivity for my opengl related app.
I have the JNI setup for two functions:
- One for setting the orientation and
- One for getting what the orientation currently is.
I am using the constants for setRequestedOrientation(int):
6 is SENSOR_LANDSCAPE,
7 is SENSOR_PORTRAIT,
4 is just SENSOR.
Now, im using config changes to handle it myself. And in this function I'm calling the java getorientation() function i setup. It is reporting correctly either landscape or portrait.
The problem comes in when i go to initialize my EGL display again. ANativeWindow_getWidth(window) is not reporting the correct width at all times. It'll work half the time. I think the engine->app->window is something being set from the parameter in android_main() and is used by egl to determine the screen dimensions.
But the value is wrong because i dont know how you go about updating the window with the correct one via config changes. anyone have any idea what i can do?

AndroidPlot: How to reset LineAndPointFormatter graph to original after zooming

Am using androidplot library to display static graphs using LineAndPointFormatter within my Android app. But now am facing some issue related to zoom i.e. As per the requirement after zooming the graph if user double taps on the graph, same time graph should go back to the original position/initial position. Check below the code snippet which am trying currently i.e.
public void resetZoom() {
newMinX = 0f;
newMaxX = 0f;
fixBoundariesForZoom();
setDomainBoundaries(newMinX, newMaxX, BoundaryMode.FIXED);
redraw();
} // With this code whenever user double taps on the graph same time graph is displaying blank means domain and range value is resetting to the original but line graph is not displaying.
Can anybody please help me or let me know some workaround to deal with this issue.
There is no built-in "reset" option. You could go through the library source and come up with something hardcoded that restores the internal defaults but it would be a brittle solution since the built in defaults could change in a future release of the library. My suggestion would be to explicitly define the boundaries etc. that you'd like to use as your default state in a method and invoke that both at startup and on reset.

Rotating MKMapKit

I am attempting to rotate an MKMapView using MapKit.
I can display a map and rotate it, however not very efficiently. I create an MKMapView larger than the view and rotate it using CGAffineTransformMakeRotation, so the the grey areas behind the view are not visible. Although I have clip subviews checked in Interface Builder, I still have the feeling this is not the correct implementation.
This method does allow me to rotate any annotations displayed as MKPinAnnotationView conforms to the CGAffineTransformMakeRotation function, but I come into problems when trying to add an overlay to the map.
I can place an overlay on using the boundingMapRect property in the class declaration but the image remains unrotated on the display. Is there a way to achieve this? Or alternatively should I be rotating the MKMapView and annotations in a different method?
Thanks in advance for any advice or information.
Are you rotating the map so that it is facing the same way the user is? (i.e. not just North = Up). If so you don't need to do any transformation stuff at all, just set the MKUserTrackingMode to MKUserTrackingModeFollowWithHeading

Resources