How to use the new Android M feature of “Text Selection” to be offered from outside of your app?

First, to clarify the question: On an M emulator, if you highlight text, you will see the new floating action mode. If you click the overflow icon, you will see “API DEMOS” show up: Clicking that brings up an activity from the API Demos app, showing the highlighted text: Replacing the value in the field … Read more

Design lib – CoordinatorLayout/CollapsingToolbarLayout with GridView/listView

With ListView/GridView, it works only on Lollipop by following code- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { listView.setNestedScrollingEnabled(true); } I think for Now CoordinatorLayout works only with RecyclerView and NestedScrollView EDIT : use – ViewCompat.setNestedScrollingEnabled(listView/gridview,true); (add Android Support v4 Library 23.1 or +)

Android Marshmallow: Test permissions with Espresso?

With the new release of the Android Testing Support Library 1.0, there’s a GrantPermissionRule that you can use in your tests to grant a permission before starting any tests. @Rule public GrantPermissionRule permissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION); Kotlin solution @get:Rule var permissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION) @get:Rule must be used in order to avoid java.lang.Exception: The @Rule ‘permissionRule’ must … Read more

Android Marshmallow: Changing permissions at run time crashes app

It’s because of additional features added from Marshmallow. You need to request from user at runtime. For this use this class which I have made. Then use it whereever required public class AppPermission { public static boolean isMarshmallowPlusDevice() { return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1; } @TargetApi(Build.VERSION_CODES.M) public static boolean isPermissionRequestRequired(Activity activity, @NonNull String[] permissions, int requestCode) … Read more

Send request over WiFi (without connection) even if Mobile data is ON (with connection) on Android M

Stanislav’s answer is correct but incomplete because only works in Lollipop. I’ve wrote a complete solution for Lollipop and Marshmallow onwards for you to route all network requests through WiFi when connected to a specific network of your choice. Kotlin In your Activity, @RequiresApi(Build.VERSION_CODES.LOLLIPOP) class RoutingActivity : Activity() { private var mConnectivityManager: ConnectivityManager? = null … Read more