Camera App in Portrait Mode - android

We are making an application which supports both tablet devices and mobile devices. We have provided different layouts for both the mobiles and tablets. We support landscape orientation for tablets and portrait for mobile.
Now we have one screen in app which allows user to open camera and take picture which then will be saved and shown to the user once the user will close camera.
App works fine for tablet devices. But for mobile devices, it crashes once the camera app is closed after taking the picture. I then found out that Camera app for devices other than Nexus(Vanilla Android in general) have landscape orientation by default (App works fine for nexus devices) and so it recreates-reinitializes my main activity (from which I have loaded my fragment) after closing that camera app.
After trying to dig out some more, I found that camera app has orientation landscape in it's source code file so I can't change that. That leaves me with 2 options :
1) I need to integrate camera in my app only -- it can be done but I don't want to do this option as it doesn't seem appropriate.
2) I need to implement some way to save instance of activity -- I have only one activity (to support tablet layout) which loads all different fragments (around 30-35 fragments I guess - may be more than that) and all this fragments have it's own callbacks to activity. The fragment which opens the camera app is also opened by some callback method in activity so it seems very complex to implement this also. There will a huge number of variables to be retained which is not good.
Please give me some other suggestion as to what other things can be done ? Otherwise I will have to integrate camera in my app itself.
Thanks in advance for your help.

Related

Some part of touch screen not working

I am working in an android project targeted for Samsung Galaxy Tab E in Landscape.
The android application starts on boot(as per requirement), after booting, Android by default loads in portrait and switches to Landscape quickly.
The app is already started(Though screen is locked), but the working area in app would be only the width equal to the width in portrait.
This issue appears when screen is locked and orientation of tablet is set to Landscape.
With reference of attached picture in link https://i.stack.imgur.com/4K5Ul.png.
P : is screen when in portrait.
L : is screen when in Landscape.
A : is working portion of L (Whose width is equal with width in portrait mode)
B : is NON-working portion of landscape.
This issue is resolved, and I have explained my case and solution which might be useful for other developers with similar issue.
The issue was not with android application itself. The issue was because android starts my application before boot completion. In my project, android app would run in accessory mode, controlled from another device.
Once the external device gets tablet during restart/power on, my android application starts to run before boot completion, I made another application (app of external device) which sends request to accessory device to sleep for a while when new device is found, so that tablet has enough time to boot and can start app.
Thank you!

Android App doesn't rotate on normal (non-large) devices

I'm writing a chat app in which I have two different layouts for normal and large devices, similar to the Telegram app. I have an MainActivity that on non-large devices has only a fragment containing the list of chats in it's layout.xml. On large devices the layout.xml also includes a fragment, where you can write in the chat.
My problem is, that on large devices (e.g. Nexus 9 Virtual Device) the app rotates fine when I rotate the device, the activities are reloaded etc. But on non-large devices the app won't rotate after it is started. I have tried this on Nexus 5X API22 and Nexus 5 API23 Virtual Devices and on a OnePlus X and a Samsung Galaxy S7 Edge, all with auto-rotate activated. There is nothing in the AndroidManifest or anywhere else in my code, that has any influence on configChanges. I let Android handle them and don't handle them myself.
I can get the app to rotate on non-large devices when I open the app, got to overview or start another app, rotate to landscape and then go back to my app through overview. After doing this, it reacts normally to rotation. This means I can then rotate it around and the layout/activity is reloaded accordingly by Android.
I couldn't find anything on this anywhere, neither on SO, nor through googling. Please help me, if you have any ideas, where this problem could stem from.

Allowing Landscape mode for specific part of the app only

I'm developing an Android Application which is locked to portrait mode for phones. In one part of the application, the user can look at some nice Graphs. In this part (only), it would be nice to allow the user to change to landscape mode - if he wants to.
I know this would be quite simple if the Graphs were contained in their own activity, but unfortunately, they are not. They are shown by Fragments which in turn are shown in a somewhat complex Tab Layout.
In other words; I want to have to whole app locked to portrait mode except when the user is in a specific Fragment. Then I want to allow him to allow him to change to landscape mode (Not neccessarily by rotating the device, other solutions are welcome too). When the user navigates away from that part of the app from Landscape mode, the portrait mode should be restored.
Is there any way this can be achieved?
you can do it dynamically this way :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

In-built android app to run only in landscape mode

I have developed an application that runs images and videos (with a default application to display them) for a certain time period.
However I want to run all these images and videos only in a landscape view. I want to lock this, irrespective of rotation settings. If possible, I would also like make it to only portrait view in future. Please advise.
It is not possible to change device orientation programmatically, you can redirect user to those setting but not possible to change from app side. e.g you can redirect user to GPS setting screen but not set it from app. Same concept apply for rotation as well.

Set system level default screen orientation for an android device

I have a project requirement to create a kiosk based application which will always be in the landscape mode,for which I am making use of a tablet running on 4.2.2.One of the modules has the functionality to make phone calls.For making the calls from my app, I invoke the default android dialer app.However,I notice that even if my device is physically in the landscape mode,at times when the default dialer app is called,it first displays its portrait layout and the quickly switches to the landscape one(which is not visually appealing).Now,since I do not have access to modify the source code of the default dialer app,I was wondering if there is a way that I can specify a system level screen orientation as landscape ?
PS: I have root access for my tablet.
Any help would be appreciated.Many thanks !
There's an app for that: Rotation Locker
You can also add the switch ro.sf.hwrotation 90 in your build.prop file

Categories

Resources