Monday, 31 October 2016

Firebase Overview

Here are some overview of Firebase Features:

Firebase analytics:

Firebase Analytics collects usage and behavior data for your app.

Firebase cloud messaging:

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4 KB to a client app.
FCM: Firebase cloud messaging (Updated form of GCM)

Firebase Authentication:

Most apps need to know the identity of a user. Knowing a user's identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user's devices.
Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, popular federated identity providers like Google, Facebook and Twitter, and more.

Firebase Realtime Database:

Store and sync data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline.
The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data.

Firebase Storage:

Firebase Storage lets you upload and share user generated content, such as images and video, which allows you to build rich media content into your apps. Firebase Storage stores this data in a Google Cloud Storage bucket, a petabyte scale object storage solution with high availability and global redundancy. Firebase Storage lets you securely upload these files directly from mobile devices and web browsers, handling spotty networks with ease.


Firebase Test Lab for Android:

Test your app on devices hosted in a Google datacenter.


RecyclerView

RecyclerView:

The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at run-time based on user action or network events.

A layout manager positions item views inside a RecyclerView and determines when to reuse item views that are no longer visible to the user. To reuse (or recycle) a view, a layout manager may ask the adapter to replace the contents of the view with a different element from the data set. Recycling views in this manner improves performance by avoiding the creation of unnecessary views or performing expensive findViewById() lookup.

RecyclerView provides these built-in layout managers:


  1. LinearLayoutManager shows items in a vertical or horizontal scrolling list.
  2. GridLayoutManager shows items in a grid.
  3. StaggeredGridLayoutManager shows items in a staggered grid.



Support older Version:
At the time of writing, less than 2% of Android devices run Android Lollipop. However, thanks to the v7 Support Library, you can use the RecyclerView and CardView widgets on devices that run older versions of Android by adding the following lines to the dependencies section in your project's build.grade file:

1- compile 'com.android.support:cardview-v7:21.0.+'
2- compile 'com.android.support:recyclerview-v7:21.0.+'

ListView vs RecyclerView

1. Reuses cells while scrolling up/down - this is possible with implementing View Holder in the      listView adapter, but it was an optional thing, while in the RecycleView it's the default way of  writing adapter

2. Decouples list from its container - so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager.

3. Animates common list actions - Animations are decoupled and delegated to ItemAnimator.



Sunday, 30 October 2016

Android Studio useful shortcut keys


  1. Alt + insert: Generate options
  2. ctrl + O: Override method
  3. ctrl + win + alt + l: indentation of XML/JAVA file
  4. ctrl + /: Comment
  5. ctrl + alt + /: block comment 
  6. Ctrl + N: Go to class
  7. ctrl + shift + F: search string anywhere in project
  8. Double shift: Search everywhere
  9. Alt + Left-Arrow  ; Alt + Right-Arrow: Navigate open tabs

NDK vs SDK android?

NDK == Native development kit
SDK == Software development kit

NDK uses native code languages like c and c++. Using native code in android does not increase the performance but increases the complexity. Therefore most of the applications does not need NDK for development. SDK is written using java programming language and runs on Dalvik virtual machine (DVM). It consists of libraries, sample codes, development tools. Mostly NDK is used for accessing things from a lower level, finally to be able to port c/c++ code from different projects.

Basically NDK is a powerful tool in the development of mobile applications. Especially if you want to develop a multi-platform application, the NDK is unbeatable in this domain. Since the same code written in C++ for Android can be easily ported and run the same way on the iOS, Windows or any other platform without changing the original code. Which actually save a lot of time in the development of applications which are developed for being run on multiple platforms; as games and other classic applications. Thing you cannot do with the SDK.

The NDK is much more limited in terms of functionality.
What you do get from the NDK is the ability to write your app in C++ and compile it to native ARM code. If you like C++ better than Java, if you have an existing C++ app that you want to port to Android, or if you just need the extra performance that only native code can offer, then by all means you should use the NDK.

I haven't done this myself, but another alternative is to write hybrid app, where the app is written mostly in Java, with selected functions written in C++ that are called from the Java code.