I am working on a game on Unity and for that I have to detect if system default font boldness is enabled in accessibility or not. For checking that I am using fontWeightAdjustment like this
Configuration config = this.getResources().getConfiguration();
int fontWeight = config.fontWeightAdjustment;
but got to know it is available only from API31. I tested on API31 its working but what is the alternate way to know the same with older API level. This code is giving different result on different devices, like Samsung Galaxy S9 using Android 10 is throwing exception that its not found but One plus device running Android 10 is sending right bold value.
Related
I'm currently working with Xamarin for developing an android app. The structure of the app is really simple yet but a big problem appeared concerning the rendering of my main page. First, it's important to know that I'm supposed to develop for target API 23 so Android 6.0.
And every time I test my application on my Android 6.0 device via USB-debugging the design is totally messed up with my only (!) button duplicated many times and the textViews mixed up over the screen (As shown in the picture link below).
Even though I am new to Xamarin and Android (and C#) I have my settings (as I think) in perfect order. The minimum API level is 21, the target SDK version 23 (Android 6.0), my device runs version 6.0.1, the target compiling framework in properties is set to 6.0, the manifest is set up as I mentioned before and even my "Designer" window with the layouts .axml is set to v23.
I really don't know what to try next, because I want to start coding further. Would be nice if sb could help me out with that.
I have already tested the code of the app on a different API level (26 I think) and it worked perfectly fine with my Galaxy S9 in Debugger mode. Everything looked like it was designed in first place.
I also tried different AppThemes in Visual Studio but not one of the 7-8 I tried worked in any way different except for the colors.
The android app does only switch when clicking the button, texthttps://imgur.com/i0xChVniew 2 into the current date and time. I'm really sure, that my code is not the problem.
Picture: How it should look (In Xamarin)
Picture: How it looks on the phone
I want to add in my manifest android:largeheap="true" based on some devices. Mostly devices running probably os 5.1 and below.Because alot of my clients are using samsung s3 , chinese , indian , pakistani phones.And I am getting lots of crashes in my firebase console. However this issue is not faced on top notch devices like google pixel samsung s8 etc.
How can I detect which devices i run largeheap, and how i run it on those devices only? I do not want to run it on devices i dont need to.
Well, you can't set this flag depending on the device. That's the true. But you can set it depending on OS version, screen size and etc. Check this answer to see how it can be done.
How can I access this through code? So I can open it for the users automatically and they don't have to hunt through the Security settings to enable it.
I am unable to find it in Android Studio using startActivity(new Intent(Settings.<>));, where <> is the list of setting screens.
Image courtesy of Android Police
There is an outstanding bug in Android 4.3 where the notification listener screen action is not listed in Settings. The current workaround is:
startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
The bug that #CommonsWare mentioned has been fixed as of Android 5.1 (API 22). You can now use this to bring the user to the Notification access screen:
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
I've tested this across multiple Genymotion instances (4.3, 4.4, and 5.1) as well as a Galaxy S3 running 4.3, and this solution has worked perfectly in each case.
Strangely however Android Studio does give me a warning when I use this field on pre-API 22 projects, despite the fact that it works without problems:
Field requires API 22 (current min is 18): android.provider.Settings#ACTION_NOTIFICATION_LISTENER_SETTINGS
I believe that this warning should be able to be safely ignored, similarly to how you can use values from Build.VERSION_CODES on any version of the platform.
Link to the documentation: Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS
In Google play (app market), if an application is not compatible to your device (for some reason, say small screen size, etc). Then it is not even shown in the list.
Now, as an app developer I never want to unintentionally add a limitation in my app that forbids it from a range of devices.
So, while developing how can I make sure that the application will be able to run on atleast the type of devices that I intend.
Also, right now I'm developing an app & testing it in on my phone with version 2.3.5. And every now & then Google changes some method names & flags.
For newer android releases, I CAN test it on emulator, but testing it on phone/tabs/etc. is a different thing.
Please suggest.
how can I make sure that the application will be able to run on atleast the type of devices that I intend.
In manifest file you can mention, which type of device you want to run your app. And for testing you can create emulators for different devices to test your app. Try to make app UI such that it runs on all devices.
Google changes some method names & flags
Whenever Android changes any thing it will always be upward compatible means if you have made app for 2.2 it will run on 2.2 and above (screen size or resolution is other thing)
Regarding UI see my answer here
Layout for 720*1280 devices
By default apps will be available to as wide a range of users as possible.
There are certain limitations you can define in your manifest file, such as not being available on small screen sizes, but they are at your discretion.
The only limitation Google imposes on you is that any user who has a lower Android version than your minimum SDK version cannot see your app. To get around this, you can either design the app for lower SDK versions (I believe building for 2.2 and up gives you access to about 95% of the user base) or maintain multiple versions of the APK.
Read this. It will really help. Next Eclipse will help you a lot, firstly you can define what you wish to support (screen sizes and hardware requirements or even if they're not necessary but may be used) in the manifest. You can run a version check and implement APIs dependent on which version of Android you're running on. That's personally what I do, I check the API level and if it's greater than or equal to the API I wish to run I run it, otherwise I attempt to find compatible code (often using the compatibility library) or alternatively drop support for that feature, for example JellyBean notifications there's not really any work around for expanded notifications but I can use the NotifcationCompat builder.
I just put an app on the market and it is showing on all phones I have except for my Acer Liquid Mini. This one:
http://www.gsmarena.com/acer_liquid_mini_e310-3711.php
I have phones with the same res screens, Android 2.2, and close enough to the same hardware specs yet this is the only phone that it doesn't show for. It is running on factory defaults. When I try to install by the browser Google just says that the app isn't compatible and no more information.
I have the minSDK set to 4, maxSDK set to 10, I'm not specifying any screen resolutions in the Manifest (as recommended by the Android Doc post Android 1.6) and install location is set to "auto".
Does anyone have any ideas?
Apparently Google has problems with knowing the hardware constraints on some devices, such as this one, my Desire with the 2.3 upgrade and my Irish Galaxy 10.1" tab. They are working to sort it out
You could try deploying you app on appslib, they got a list of devices supported. You can choose a set of features required by your app and see the devices that will be able to run it.
I can't promise that both Android Market and appslib will give you the same results, i.e. will associate a device to the same requirements but that's a track to follow.