Posts

Flutter – Cross Platform App Development Framework from Google

Image
Flutter is a new cross-platform app development framework from Google that allows apps to be created for both Android (KitKat or later) and iOS (iOS 5 or later). It's all  open source  and still being developed by engineers at Google and you can follow two engineer's profile at  Chinmay Garde  &  Devon Carew . The main focus of Flutter is to provide low-latency input and high frame rates (60fps) for high performance on Android & iOS. Flutter Architecture Flutter is built with C, C++, Dart, Skia (a 2D rendering engine), Mojo IPC, and Blink’s text rendering system. To have better understanding of the main components, please check the below architecture diagram:- High-Level Overview of Flutter Architecture Flutter has three main components:- A heavily optimized, mobile-first 2D rendering engine (with excellent support for text) A functional-reactive framework A set of Material Design widgets, libraries, tools, and a plugin for Atom H...

Android L Developer Preview

As you all know last month at Google I/O we got glimpse of the L Developer Preview . It provides us an advance look at the upcoming release for the Android platform, which offers new features for users and app developers. Android is getting a major overhaul with its next version, which is currently being referred to as Android L. The new version will tout more than 5,000 new APIs, multiple new features, a new runtime engine, and a major user interface makeover. The Android SDK has been released and, for the first time, you will be able to preview the new version on a Nexus 5 or 7 device. I thought let's give a try to L Developer Preview, so I downloaded the SDK & setup my development environment. After that I installed the L Preview System Image on Nexus 5. To flash the image onto your device please follow these  instructions . You can have a look at Nexus 5 with L Developer Preview as follows:- Now it's time to get our hands on L Developer Preview APIs ...

Check whether device is phone or tablet(7" or 10")?

Sometimes we have requirements to check whether device is phone or tablet & even for tablet whether device is 7" or 10". Following method will help us if the device is tablet or phone. If device is tablet method will return true, otherwise it'll return false. public boolean isTablet(Context context) { boolean isTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; return isTablet; } If above method return true, which means the device is Tablet. Now we have to detect whether device is 10" tablet or not. If device is 10" following method will return true, otherwise it'll return false. public boolean isXLTablet(Context context) { boolean isXLTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; return isXLTablet; }

How to check whether current file is audio/video/image?

The below method will return whether current file is audio file or not:- public static boolean isMusic(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if (type == null) return false; else return (type.toLowerCase().startsWith("audio/")); } The below method will return whether current file is video file or not:- public static boolean isVideo(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if (type == null) return false; else return (type.toLowerCase().startsWith("video/")); } The below method will return whether current file is image file or not:- public static boolean isImage(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton().getMimeTypeFromExtensi...

ART or Dalvik? Which one is better?

ART (Android RunTime) is the next version of Dalvik. Dalvik is the runtime, bytecode, and VM used by the Android system for running Android applications. ART has two main features compared to Dalvik: Ahead-of-Time (AOT) compilation, which improves speed (particularly start-up time) and reduces memory footprint (no JIT). Improved Garbage Collection (GC). An ahead-of-time (AOT) compiler is a compiler that implements ahead-of-time compilation. This refers to the act of compiling an intermediate language, such as Java bytecode, into a system-dependent binary. Hence your apps are compiled to native code once, and stored on your device to run effectively as native. This differs from the traditional VM model, which interprets bytecode. Interpreters are slow, so VM developers added a technology called Just-in-Time (JIT) compilation, which compiles (and hopefully optimizes) your code to native code on-the-fly. Dalvik is a JIT'ing VM. The downside to JIT is that the JIT compiler ...

How to check support for Call & SMS on Android device?

Sometime we have requirements to implement call & sms support with in our android app. Now how to check whether device has support for call & sms feature. To verify, we can check the device phone type, which indicates the type of radio used to transmit voice calls. In addtion to this we can also check that the device has a telephony radio with data communication support or not. The method is as follows:- public static boolean supportCallAndSMS(Context context) { boolean isSupported = false; TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); boolean isPhone = !(telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE); boolean featureTelephony = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEPHONY); if(isPhone && featureTelephony) { isSupported = true; } return isSupported; }

Detect fake/mock GPS apps on Android device

While we are working with location APIs in any Android App, we have to make sure that user is not using any fake/mock GPS apps. We can detect fake/mock GPS apps using two ways: Detect mock location is enabled in developer settings. Detect apps installed on device who are using mock location permissions. To detect the mock location settings:- public static boolean isMockLocationSettingsON(Context context) {         // returns true if mock location enabled, false if not enabled. if (Settings.Secure.getString(context.getContentResolver(),         Settings.Secure.ALLOW_MOCK_LOCATION).equals("0")) {        return false; } else { return true; } } To detect the mock location permissions:- public static ArrayList getListOfMockPermissionApps(Context context) { ArrayList mockPermissionApps = new ArrayList (); PackageManager pm = context.getPackageManager(); List pa...