Showing posts with label API Level 14. Show all posts
Showing posts with label API Level 14. Show all posts

How to Determine if Android Device Supports WiFi Direct

public static final String FEATURE_WIFI_DIRECT was added in API level 14
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports Wi-Fi Direct networking.
Constant Value: "android.hardware.wifi.direct"
Here are some examples of Android Phones with Wi-Fi Direct.


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolWifiDirectSupported

3. Set the Minimum and Target SDK version  to 14 or greater. 

4. In the onCreate method, add the below code. This will return the Wifi Direct availability to a boolean named bolWifiDirectSupported. It will then display a toast displaying the Wifi Direct availability of the device to the user.

bolWifiDirectSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
if (bolWifiDirectSupported) {
Toast.makeText(this, "Device supports Wifi Direct", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT support Wifi Direct!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_WIFI_DIRECT

android:drawableEnd - Set drawable to the end of the text, in TextView, in XML

Set drawable to the end of the text, in TextView, in XML

android:drawableEnd was added in API Level 14 
Related Method:
setCompoundDrawablesRelativeWithIntrinsicBounds - Add a Drawable to the End of Text, in a TextView, in Java

The drawable to be drawn to the end of the text.

1. Add a TextView.

2. Add a drawable named myImage.  

3. Ensure to change the minSDKVersion to 14, or greater.

4. In the main.xml file, add the below line

  <TextView
    .... 
      android:drawableEnd = "@drawable/myImage"
  />
 
5. Compile and run!

Related Articles
Resources:
developer.android.com/reference/android/widget/TextView.html#attr_android:drawableEnd
http://developer.android.com/reference/android/R.attr.html#drawableEnd

android:requiresFadingEdge

added in API Level 14

Defines which edges should be faded on scrolling.

Ensure to change the minSDKVersion to 14, or greater.

android:requiresFadingEdge = "none"
android:requiresFadingEdge = "horizontal"
android:requires:FadingEdge = "vertical"

non - No edge is faded
horizontal - Fades horizontal edges only.
vertical - Fades vertical edges only.

Related Articles:

Resources:
http://developer.android.com/reference/android/view/View.html#attr_android:requiresFadingEdge
http://developer.android.com/reference/android/R.attr.html#requiresFadingEdge



android:textAllCaps - Capitalize all Text in a TextView, using textAllCaps

How to Capitalize all Text in a TextView

added in API Level 14

Present the text in ALL CAPS.
(For EditText, it displays it is ALL CAPS, but I am not able to edit it for some reason. :/ )

1. Create an Android project, if you don't already have one.

2. Add a TextView in the main.xml file.

3. Ensure your minSdkVersion is 14 or higher.

4. In the main.xml file, add the code below.

<TextView
        ...
       android:textAllCaps = "true"
/>

5. Compile and run!
http://developer.android.com/reference/android/widget/TextView.html#attr_android:textAllCaps
http://developer.android.com/reference/android/R.attr.html#textAllCaps