I have an Activity, which has a Fragment, inside of which is a ViewPager of images. In the ViewPager, there might be certain images which are sensitive, and the viewer should not be able to take a screenshot of (only) those. When such an item shows, I do:
fragment.getActivty().getWindow().addFlags(FLAG_SECURE).
And then in that fragment's onDestroy (or ViewPager's swipe), I clear that flag on the window.
This works perfectly on Android versions 6.0 and above: when that particular image is open, screenshots are blocked.
However, on Android 5.x and below, the flag update does not take place till there's a configuration change on the hosting Activity.
Does anyone know why this happens? And what's the best workaround?
I found some references here on StackOverflow, talking about the problem and a workaround, but (a) nothing explains why there's this discrepancy and (b) the workaround suggested is very, very high friction: it flashes the entire screen black.
References:
How to disable screen capture in Android fragment?
Related
i have a problem with the gui in my android (smartphone) application.
At startup everything is fine, but after some time the GUI starts to get messed up. Some elements ore not drawn completely, sometimes im getting a full black screen in some of my tabs. And some animations do not work anymore.
I already tried to switch off hardware acceleration in application and activities, but that did not help at all.
The appearence of the bug is rather random, but i have the feeling that switching between background and foreground sometimes triggers it.
The application is rather dynamic. I have 4 tabs that are shown in a self programmed tab view, so everything is running in one activity. the content of the tabs also changes by user input or other triggers. This is done by loading predefined xml views and animations.
Anyone any ideas?
I now resolved the problem by refactoring the whole project and use the fragments api of android to generate my views instead of using my own solution.
I still have no clue why the rendering of views randomly failed or produced incomplete views without any log errors but perhaps this will help others with the same problems.
A very strange problem that cause the app to draw ontop of itself without cleaning the previous frame.
Its a bit hard to explain, see the next image:
Some other symptoms of this problem:
If I start it on emulator with GPU, the problem occur.
However if I start the emulator without GPU, it does not.
The actual device that I use is connected to a monitor using HDMI. Maybe it is related.
Any help will be highly appreciated.
This looks like a very similar problem I've posted before (link here) .
The problem is that I tried to use 2 tricks for optimization - have an empty background for both the window and its views.
The reason is that there is the window of the activity already has a default background, but when you remove it, and the views don't have a background, Android doesn't "clear" the content with the background, so it smears...
Do note that this "bug" might occur on some devices yet on others it would work fine.
In short, the solution is to set a background to either the window or its views.
I'm building an html5 wrapped iOS / Android app with Trigger.io.
I have a problem on Android with a grey background appearing on the screen in some occasions after the virtual keyboard has closed, or after the phone has changed orientation.
Example screenshots are shown below.
The grey background is after the end of my app's page. Sometimes it is visible for a split second, other times it stays visible until you make an action such as scroll the page, bring the keyboard back, change orientation.
It's pretty jarring to look at.
I'd ideally like to stop the issue occurring, but as a temporary fix I'd be happy with being able to set the grey to my own background colour to make it less noticeable.
This looks like the HTML's not being re-drawn when the keyboard disappears... does it clear up if you do something to trigger a render?
Are you using a framework to handle the UI here? Something that might be trying to do something clever based on the visible viewport?
From what I can tell, the root of the issue is in the webview not re-drawing correctly, or something in your JavaScript failing to respond to the viewport changing size.
You could try running the app on the "web" target (instead of Android) then opening it in your phone's browser: if you can get far enough into the app to create the same effect it would help isolate the problem to the webview rendering or your JS.
I had a very similar issue in my project, in my case on Android 2.3.5 but not on Android 4.*. The cause in my case was not setting a window soft input mode for the associated activity in the manifest:
android:windowSoftInputMode="adjustPan"
Instead, the window was resizing when the keyboard appeared but apparently not resizing once more when the keyboard disappeared.
More details can be found here.
I almost went crazy with the same issue. I finally found out that this largely depends on the device you are using. I had a similar problem : Fixed elements (HTML) break after android keyboard dissapears?
And I am also using trigger.io. This doesn't happen with some devices. Could be the particular OS in android or could just be the way the specific device handles the memory latency.
I have looked for this but I go with #jamesbrady in that the HTML doesn't redraw. The problem in trigger is that you cannot edit the
android:windowSoftInputMode="adjustPan"
because the activity tag in the AndroidManifest.xml updates on each run. You would need to build a private module for that.
Is it possible like in topic, I mean start camera intent and before opening that view set screen not to see rotating screen effectc? I was trying to use overridePendingTransition after startingActivityForResult, I tried also to put this overriDePendingTransition while calling onPause and OnResume. Somehow camera uses own animation. I would like to disable that animation. Is is possible? This effect doesn't affect in android 2.3.x. Does it might have connection with touchWiz?
TL:DR
As of KitKat 4.4.2 this still does not seem possible. Tested with AOSP phone app, Nexus 5 experience Phone App, Maps, AOSP Browser and Chrome.
(I would have put this in a comment, not enough rep yet. It's still an answer per-say, though not a solution to the problem)
Only thing I can say about why it's not possible is:
If you could force a transaction on the "external" intent through
your own app code, you would be basically injecting your animation
into another publisher's app, which would be a MAJOR design flaw
in the Android framework.
My guess is this will never be possible unless the OS manages such transactions in a bullet-proof way to both ends. Some AOSP branded-builds and custom Launchers can change default animations for ALL activity starts/resumes though (or even use no animations at all).
So I'm making an app for my company, for a android tablet to be used like a "kiosk". Users should only be able to use this one app, and be able to do nothing else on the tablet.
I've found a solution by using WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED on the activities. However, when I switch to another activity in my app, the leaving activity fades out, shows the lock screen quickly and then the next activity appears.
I'm guessing that this is because the FLAG_SHOW_WHEN_LOCKED is in onCreate(), as opposed to earlier in the Activity creation process.
Is there anywhere else I can put this flag, or any other way to prevent the lockscreen to be shown between activities? It's not a huge issue, but it is a poor user experience.
It is a Samsung Galaxy Tab 10.1 Running ICS 4.0.3.
I was able to best fix this by using Fragments and using FragmentManager to swap out the fragments in the activity, so the lockscreen was never shown, since I never left the activity. The android developer guide has a good example for this.
http://developer.android.com/reference/android/app/Fragment.html