Get device volume in Xamarin Forms - android

Is it possible to read the volume level of an android device?
There are 3 different volumes: Ringtone, music and alarm. I would like to find, if the music is muted.
I've already tried AudioManager, but it doesn't seem to work properly on android SDK version 10 (if it works fine on your device, please let me know).
I've searched a lot and nothing seems to work, any suggestion will be appreciated 😉

Android Q has changed the way applications access files in the external storage.
Before your app is fully compatible with scoped storage, you can temporarily opt out by using one of the following methods:
Target Android 9 (API level 28) or lower.
If you target Android 10 (API level 29) or higher, set the value of
requestLegacyExternalStorage to true in your app's manifest file:
<manifest ... >
<!-- This attribute is "false" by default on apps targeting
Android 10 or higher. -->
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>
For more details you could check Google Docs .

Related

Android SDK - What to download?

I want to develop android applications, i've downloaded all the necessary.
One last question:
if i decided to create apps that are compatible with for example starting from API 11 and later, what is the strict necessary i need to download from Androis SDK Manager?
I need to download all?
What are Android SDK build-tools?
What are other downloads in the list?
Can someone post a screenshot of strict necessary scenario to do what i'm need?
thank you
You don't need to download all Android SDK, just get Android 3.0 (API 11) and Android 5.0 (API 21) and declare the min and max targetsdk in the manifest file.
you have to declare your desire version using this line
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
in manifest file. for more info check this out http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
EDIT
you don't have to download anything for make strict versioning.
android:minSdkVersion
Like the name suggests, defines the minimum API level your application works on. This is used by Play Store to detect if the application is compatible with the users device. So, if your minSdkVersion is 7, Play Storewill show the application to devices from API level 7 (2.1) and up. This attribute should be set by all apps!
android:maxSdkVersion
This defines the maximum API level your application works on. Again, Play Store uses this to detect if an application is compatible with a device. Please note, that there in most cases is no reason to use this! it is perfectly possible to create a single APK which works on every API level from your minSdkVersion and up!
android:targetSdkVersion
Unlike the other two attributes, this is used by the Android platform itself. This attribute should be set to the maximum API level you tested your application on. If not set, this will default to your minSdkVersion.
you can also visit this to get more details http://simonvt.net/2012/02/07/what-api-level-should-i-target/

Is there a way to change a project from using API 12 to API 8

I set up my project to use Android 3.2 (API Level 12), but it seems like a lot of phones are still using Android 2.2 (API Level 8).
Is there a way to change my project from only supporting Android 3.2+ to supporting back to Android 2.2?
yes...just change the minsdk number in the manifest. You have to be sure that you don't use any feature that is not supported though...
in your AndroidManifest.xml add this line:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
android:minSdkVersion tells the Store what the minimum version you are targeting is. In this case 2.2. Devices less than 2.2 won't be able to download your app.
android:targetSdkVersion tells the store what the best version you are developing for is. In this case 4.1. Devices over 4.1 can still download your app but certain features may run in compatibility mode.
NOTE: When you setup your project to use 3.2, all you did was select the Android SDK you wanted your IDE to use when checking and compiling your code. Without the uses-sdk line in your manifest you've targeted nothing.
Right Click Project -> Properties -> Android -> Select SDK version
Update Manifest, min/target api. (as others have described by others).
Go to your Manifest.xml file and edit the minSdkVersion to 4. That will set it way back to 1.5 or something like that :). You can make that number higher if you want to suit a higher API, but I like compatibility.

Relation between android:minSdkVersion, android:targetSdkVersion and "target"

So, I'm a little confused, I thought I understood the meaning of android:minSdkVersion, android:targetSdkVersion and target in project properties.
Right now I got these set to:
android:minSdkVersion="7"
android:targetSdkVersion="13"
And:
target=android-15
in project->properties->Android->Project Build Target.
When I try to run this application application on a device with Android 2.3.3 installed, I see a red cross against the device name but the application runs fine on it none the less.
What am I missing? If I'm building against 15, how is it running on android-7? This confusion stated after I integrated AdMob into my app which states it require minimum SDK level 13.
To describe one at a time:
android:minSdkVersion helps Google Play filter apps for the user based on their device. For instance, with minSdkVersion="7", someone browsing with a device that only supports 6 won't see your app on Google Play, and thus won't download it, find it doesn't work, and leave a bad review :)
android:targetSdkVersion is a signal to the device about which version of the API your app was tested against. New behaviors are often available by default with new versions of the platform, for applications that target at least that version of the platform. For instance, by setting your targetSdkVersion to 11 or higher, you get an overflow menu in the ActionBar (for Honeycomb and up devices) instead of the "legacy menu button of shame".
project.properties target is a signal to your local build system regarding which version of the platform you should be compiling your code against. Generally it's best to just set this to whatever you have set for the targetSdkVersion.
What am I missing? If I'm building against 15, how is it running on
android-7?
Android maintains backwards compatibility for just this reason. When you use API's that were added in version 15 of the platform, obviously they won't be there on a device running an an older device.
However, it's possible (and encouraged) to design your application in such a way as to take advantage of features added on new platforms, but "degrade gracefully" such that your application continues to run on older ones. There's an Android Training lesson on just this topic, called Supporting Different Platform Versions.
android:targetSdkVersion="13" Indicates that this application has been build by keeping the sdk 13 as target, to use its feature to full potential
android:minSdkVersion="7" indicates that it works on sdk 7 and above, but some of its features can be stripped down if certain features are not available in lower sdk. ie(less than sdk 13)
android:minSdkVersion="7" means you can't run this app in devices under 2.1(API-7). android:targetSdkVersion="13" the app is built targetting this API. the build target will be set to 13 and the methods and stuffs that are available till 13 will work.
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

android app to be runned only in 2.2 and 2.1 versions

in my app i have two set of designs. One design is for the android devices version of 2.1 and 2.2, the other design is for devices of 2.3 and above.
Now the problem is i take a build setting as follows in my manifest file
<uses-sdk android:minSdkVersion="7" />
<uses-sdk android:maxSdkVersion="8" />
My android project properties in been set to 2.2. When i run this build in 2.3.4 devices it gets run properly. How does it happens?
I am planning to submit the app with multiple apk files in market. How to block my apps
one build to be run in 2.1 and 2.2 and
the other build to get run in 2.3 and above
I just tried setting only <uses-sdk android:minSdkVersion="7" /> or <uses-sdk android:maxSdkVersion="7" /> or <uses-sdk android:maxSdkVersion="8" /> or
<uses-sdk android:targetSdkVersion="8" /> then also it gets run in all devices of 2.3.4 devices
Please help me friends....
Hey as per the android documentation :
Introduced in: API Level 4
Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation. Google Play will continue to use the attribute as a filter, however, when presenting users with applications available for download.
You might want to have a look at last few lines of this link
EDIT1:
Also have a look at the Warning
Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.
According to documentation:
Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#max
Alternatively, you can check API version at runtime and block the use of your app.
http://developer.android.com/reference/android/os/Build.VERSION.html
You can install it using the adb or directly downloading the apk through a website.
The minSdk and maxSdkVersion is checked only when its installed from Android market. Devices with versions out of this range will not see your app in the market.
You need to use PackageManager Class for Version Specific Application. There is a method called getPackageInfo() which returns an object of PackageInfo. From this PackageInfo, you can fetch values of Version Name & Code.
Now you have values, so use logic and implement it

App to Support Android 2.1 and Apps2SD

I currently have an app which is set to support Android 2.2 and have the Android Manifest file the line of code to enable the app to be installed on to the SD Card. I want to be able to make the App also support Android 2.1 and above. Is there a way I can do this or do I need to have two separate apps. One for Android 2.1 and another for 2.2 and above.
Thanks for your help
No.
Simply in the Manifest editor add the uses-sdk in "Manifest extras" and set only the minSdkVersion attribute to an API version of your choice. Don't set the Targetsdkversion.
This works for my apps.
I set:
android:installLocation="auto"
and
<uses-sdk android:minSdkVersion="7"/>
You can find all this information on the Android dev guide

Categories

Resources