Posts

Showing posts with the label Android

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...

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...

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...

Getting java.lang.NoClassDefFoundError after upgrade to ADT 22

Image
After updating your Android SDK & ADT plugin, some fellow developers may be facing java.lang.NoClassDefFoundError at runtime even dependency libraries already added to the project.  To fix this issue, I found the solution at Google adt-dev group . The solution is as follows:- It was indeed an issue with 'Order and Export' of the Java Build Path. When upgrading, the 'Order and Export' of the new 'Android Private Libraries' is not always checked. And the android-support-v4.jar is now in this 'Android Private Libraries' section.  To fix this, go to 'Order and Export' and check 'Android Private Libraries'. Then refresh/clean/rebuild. After you done this 'fix' for a library project, you may need to just close and re-open any depending project, because they may not see this 'fix' immediately.  

Difference between rooting & unlocking bootloader

Lots of Android users are still don't know the difference between rooting & unlocking bootloader   and they will get confused between these terminology. There is a major difference between these two & also they are related to each other. The difference & relation is as follows:- Rooting -  Rooting a device is a method to gain full access to the device operating system (Android). However, rooting only affects your operating system. With root you are able to perform all the administrative stuff, such as access to write files to the system partition or delete all the files or uninstall system apps. Root enhances your privileges and you are able to change almost anything inside of your ROM. Unlocking Bootloader -  Bootloader is the instance that calls the operating system (Android) and manages direct access to the device's partitions. Having an unlocked bootloader enables you to flash custom roms, custom kernels, recoveries and so on. Relation betwee...

Debug Android App using Log

Debugging during development process always play a key role, so lots of developer use logging. Android provides us a great interface while dealing with logcat. The problem I saw with few developers, they simply use the log for debugging and never remove their log statements before creating final apk & which result in decreased application performance. To avoid this situation, you can create a custom log class & can control the amount of information visible in logcat. The CustomLogger class is as follow:- public class CustomLogger {               public static void d(String tag, String msg) {                 if (Log.isLoggable(tag, Log.DEBUG)) {                         Log.d(tag, msg);                 }         }         public static void i(String tag,...

Open webpage using Android app and mark URL as Bookmark

Few of fellow developer friends drop me a query about an app which open a browser with predefined URL & mark that URL as bookmark. The solution is as follows:- To open a browser with in a app, you have to create a browser Intent.         private void browseURL(String url) {             Intent browseIntent = new Intent(Intent.ACTION_VIEW);             browseIntent.setData(Uri.parse(url));             startActivity(browseIntent);         } Now before saving this URL as a bookmark, you need to check whether it's already exist or not. So to read bookmarks we need to access Android's Browser content provider using ContentResolver object. You can then use the ContentResolver's methods to interact with whatever content providers you're interested in. private boolean isBookmarked() {             boolean isBookema...

Google - App Inventor for Android

Hi Readers, Last Saturday 30th OCT 2010, I got the opportunity to attend the meet up for Google's App Inventor by the  Code Android Malaysia Group . The meetup is great, learned new stuff & explore few Android devices (WITS A81E, Haipad G10, Zenithink ZT-180 ePad, Dell Streak, Samsung Galaxy S, HTC Dream/G1, & Nexus One). App Inventor -  App Inventor is a web based tool from Google that makes it easy for anyone (programmer & non-programmer) to create mobile applications for Android-powered devices. It provides us visual blocks which help us to create mobile applications by drag-and-drop functionality. Some of the few features of App-Inventor are listed as below:- No syntax  : No need to remember the coding syntax of programming languages. Visual Blocks  : The components and functions are organized into blocks. Need to find relevant block & used that function by drag-&-drop feature. Functionality based on Events  : "When this event ...

How to get IMEI on Android Devices?

Image
Hi Readers, As per your queries about IMEI on Android devices; I am posting this article, please do let me know with your feedback and further queries. The solution is as follows:- Device, network, SIM & data state related info on Android platform is managed by TelephonyManager. Your application can use the methods defined in this class to determine the desired information. Please note, you cannot instantiate this class directly; instead you need to retrieve a reference to an instance like this:- String serviceName = Context.TELEPHONY_SERVICE; TelephonyManager m_telephonyManager = (TelephonyManager) getSystemService(serviceName); To access some telephony information you need to set appropriate permission in your application manifest file, because few informations are permission protected. In our case we need to set permission for our app:- Now let's start with actual source code to retrieve the information:- public String findDeviceID() {       String de...

Block a Call

Hi Readers, Again while working on my blog, I found that some one of you are looking for an article on "Block a Call". But I am not clear about the stuff that you are looking for using J2ME or for some other technologies. No issues, I'll try to explain about it. AFAIK, You can not block a call or SMSs using J2ME APIs. Because MIDlet can only execute within "Sandbox". Now if you are trying to support this kind of functionality in your application, then you need to know about the market segment and the device penetration ratio in that market. So that you can build your app using different technologies. Let me give you more brief idea about it using an example:- Suppose we are targeting XYZ market and the device penetration ratio is as following for that market segment:- Nokia S60 & other Symbian  devices - 45% Nokia S40  & other Java devices - 30% Android, iPhone, Blackberry  & other devices - 25% So now, you can target first 45% devices using th...

Android 2.0 platform release

Hi Readers, Today Google released Android 2.0 platform for mobile devices, it bundled with many new features for user and developers and also there are few changes in the Android framework API. It can be deployable to Android-powered handsets by November 2009. Android 2.0 Platform Highlights Now user can  add multiple accounts to device for email and contact synchronization, including Exchange accounts (Depends upon the Handset manufacturers). Combined inbox to browse email from multiple accounts in one page. Developers can create sync adapters that provide two way synchronization with any backend. Quick contact API provides instant support for communication with contacts. For eg. selecting the contact photo and you will get the list of all the available way of communication. This feature is also available in SMS, Email and Calendar. Search functionality for all saved SMS and MMS messages and also support auto delete features for oldest messages when a defined limit is re...

Android 1.6 Platform - "Donut"

Image
Hi Readers, Welcome again and today we will discuss about Android 1.6 SDK. The Android developer team has announced the release of the Android 1.6 SDK on 15 Sep 2009, with the biggest news from the release support for different screen sizes, CDMA based networks. Donut is update with new battery usage feature which gives you the information of battery consumption by any application. Also there is update for camera application. We are going to discuss these features in detail now:- Search Feature:-  Android 1.6 comes up with redesigned search feature, which helps user to search quickly, efficiently and consistently across multiple applications (Contacts, Browser, and the web) directly from home screen. The system constantly learns which search result is more relevant based on what is clicked. So popular relevant contacts or apps which are previously used will bubble up to the top when user types the first few letters of a query. The search framework also provides developers a...

Motorola's first Android handset - CLIQ

After long time Motorola comes with new Android handset named " Motorola CLIQ " at Mobilize 2009 . Frankly speaking I am really waiting for Motorola's new device. First look of Motorola device is really impressive. Now one question is coming in your minds what is more special about it, there are already 4 to 5 handset present in market. So, readers it has something special in it; to find what is that we just explore this handset. The specific feature which makes Motorola CLIQ different from other Android handset is " MOTOBLUR ". Customized home screens are the latest trend and widely used in various devices, so Motorola come with custom Android UI. Motorola's MOTOBLUR is not just an Android screen/theme, but an integrated service that pushes updates from almost all social networks straight to device's home screen. Some of the following features which we'll also see in upcoming Motorola's devices. As I mentioned earlier social networking feature ...