Hello I have got an Activity, where I have multiple Fragments inside, where AsyncTasks are running. My current problem is, when I change the orientation of device, while AsyncTask is doin stuff, App is crashing. As far as I could read from some threats, the addigin "screenSize" like:
android:configChanges="orientation|screenSize|keyboardHidden">
should solve that problem. But now, my app is crashing every time I change the orientation - what does screenSize exactly do, and why is my app crashing while changing its orientation?
edit: is there any special thing I have to give attention while using screenSize concerning my fragments - so the app does not crash?
thank u
See this link for your error: https://gist.github.com/daichan4649/2480065
If you don't want to re-create the fragment on OnCreate, you should use setRetainInstance(true) as described in the link.
Related
I'm developing an app. I have implemented dark mode by creating colors-night file , using a switch and appCompatDelegate. I have written some code so that the app doesn't follow the system when phone's dark mode is on . And it works properly. Yet, the Splash screen does not obey and appears dark-colored when phone's dark mode is on(while the app continues light). I know this happens because the system reads the night resources before launching. (I figured it out since disabling dark mode in the onCreate method in SpashActivity or in Application does not work(and did some research) ). Adding "forceDark = false" on xmls doesnt work either. Does anyone know how to fix this?
I know it would be better to leave it this way since it is user's preference but i want on the first use, the user to see my company's colors and logo and then, choose the dark theme. Which, i also cant find how to change. I mean change dynamically splash activity's color depending on the sharedPreferences. (as i said before, doesnt work).
Thank you in advance :slight_smile:
This may be a silly question but I have the following situation: I want to setup my window layout every time the app is open, for example changing the status bar color. So I created my Application file because I heard it is better if you check something like this in the application file and not in the MainActivity.
Problem: How can I call the getWindow() method without an open activity.
Thanks for helping.
A bit tricky, but you can use Window manager in background-service to display your views without opening an Activity.
Also, for API Level 26+ (Oreo or above) you have to start your service as foreground service
I saw that youtube app can minimize to small window that displays over all other windows.
I want to do the same with my app.
What strings in manifest (or any other string) do it?
Thanks,
I am about this:
Take a look at google documentation about this topic, it is called picture-in-picture
You need to add the first two lines to your activity which will handle Picture in Picture (PIP) mode.
The third line needs to be added so that your activity will not relaunch once layout changes occur, such as device screen rotation.
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
You can find more information about this in the android documentation.
Here is a tutorial on how to implement it.
You can refer to the following tutorials which are nice to understand
picture in picture feature
https://medium.com/#mujtahidah/making-picture-in-picture-android-4120ac73efb4
http://www.zoftino.com/android-picture-in-picture-mode-example
Any help would be great with my issue. Basically I'm using this tutorial and its a web view fragment. So I got rid of the WebView and made new activities. My issue is connection the activities with the drawer so then every thing goes to a different activity. Once again, any idea on how to do this would be helpful.
I would recommend this tutorial instead.
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
I've used it and I have a functioning application at the moment. You can download the source, change the text and images if you'd like.
I'm just getting started with Android dev, done a few tutorials, now I'm working on a simple app. On both the emulator and my phone (Android 4.0.3 emulator, Android 4.1.1 Atrix HD) apps are displaying in what I think is Holo Light. I'd rather have it be Holo Dark, but when I add the following line to the application block in the Android Manifest file: android:theme="#android:style/Theme.Holo" the app compiles fine but force closes as soon as I open it.
What am I doing wrong? I'm sure it's something really simple, but as I said I'm new to this. Thanks in advance, y'all!
If you want to use a theme for all the activities of your application then you need to use
<application android:theme="#style/CustomTheme">
in AndroidManifest.xml.If you want a theme applied to just one Activity in your application, then add the android:theme attribute to the activity tag instead.So need to know what type you use in your application.However see these things which will clear you more..
http://developer.android.com/guide/topics/ui/themes.html
http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html
The simplest thing you can do and you should always do is to read logs why does it crash. The log will tell you the reason of you crash. Please post the reason including logs from Logcat and only then ask about fixes:)