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.

Monday, 26 September 2016

How to install Android Studio on Ubuntu



  1. Download Android-Studio [Download]
  2. Extract downloaded folder
  3. Copy folder into home directory
  4. Open terminal (press: ctrl + alt +t)
  5. Type following commands:
  6. cd android-studio/bin [Enter]
  7. ./studio.sh [Enter]

Inforoid - Information about Android





1- How to find SHA1 key?

Method 1:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 

write above line in android studio terminal and press enter

Method 2:
If you are using android studio use simple step

  1. Run your project
  2. Click on Gradle menu
  3. Expand Gradle task tree
  4. Click on android -> signingReport and see the magic
  5. It will tell you everything
_______________________________________________________________________


2- Prerequisite for Android studio 2.1.2: 

JDK  version > 1.8
Set JDK path to 1.8: Project structure
Set Android SDK path: Project Structure

_______________________________________________________________________

3- Useful shortcut keys android studio:

Alt + insert ==> Generate options
ctrl + O ==> Override method
ctrl + win + alt + l ==> indentation of XML file
ctrl + / ==> Comment

_______________________________________________________________________

4- What is instant run?

With Instant Run, you can push changes to methods and existing app resources to a running app without building a new APK, so code changes are visible almost instantly.

_______________________________________________________________________

5- AVD stand for?

Android Virtual Device

_______________________________________________________________________

6- ID naming conventions XML:

button_save_<activity_or_layout_name>
button_cancel_<activity_or_layout_name>

_______________________________________________________________________

7- Online json editor:

http://www.jsoneditoronline.org/

_______________________________________________________________________

8- Splash Screen Android:

Android splash screen are normally used to show user some kind of progress before the app loads completely.

_______________________________________________________________________

9- WebView:

WebView to display HTML pages.

_______________________________________________________________________

10- SQLiteDatabase Path: 

/data/data/<Package-Name>/databases/<DB-Name>.db

_______________________________________________________________________

11- What is Application Class in Android?

Introduction:
If we consider an apk file in our mobile, it is comprised of multiple useful blocks such as, Activities, Services and others.
These components do not communicate with each other regularly and not forget they have their own life cycle. Which indicate that they may be active at one time and inactive the other moment.

Requirements:
Sometimes we may require a scenario where we need to access a variable and its states across the entire Application regardless of the Activity the user is using, example is a user might need to access a variable that holds his personnel information like name that has to be accessed across the Application, we can use SQLite but creating a Cursor and closing it again and again is not good on performance, we could use Intents to pass the data but its clumsy and activity itself may not exist at a certain scenario depending on the memory-availability.

Uses of Application Class:
Access to variables across the Application, you can use the Application to start certain things like analytics etc. since the application class is started before Activities or Services are being run,
there is a overridden method called onConfiguration() changed that is triggered when the application configuration is changed (horizontal to vertical & vice-versa), there is also a event called onLowMemory() that is triggered when the Android device is low on memory.

_______________________________________________________________________

12- Conversion of Eclipse project into Android Studio project: 

1) Open eclipse project folder
2) Open Project.properties file and remove last line
3) Open android studio and import eclipse project
4) Change app gradle and project gradle
5) Change Manifest (app tag, main tag)
6) Import module if any
7) Module path in app gradle

_______________________________________________________________________

13- Dropbox chooser API:

https://www.dropbox.com/developers/chooser#android

_______________________________________________________________________

14- Google Drive chooser API:

API:http://www.101apps.co.za/index.php/articles/android-apps-and-google-drive-a-tutorial.html

_______________________________________________________________________

15- GCM: Google Cloud Messaging

Send data from your server to your users' devices, and receive messages from devices on the same connection. The GCM service handles all aspects of queuing of messages and delivery to client applications running on target devices, and it is completely free.

Push messages from your back-end servers to tell your apps that there's new content for the user, or other data to sync.

FCM: Firebase cloud messaging (Updated form of GCM)

_______________________________________________________________________

16- Volley:

It integrates easily with any protocol and comes out of the box with support for raw strings, images, and JSON.
Volley is not suitable for large download or streaming operations, since Volley holds all responses in memory during parsing. For large download operations, consider using an alternative like DownloadManager.

By default all the volley network calls works asynchronously, so we don’t have to worry about using asynctask anymore.

_______________________________________________________________________

17- android:layout_padding vs android:layout_margin:

android:layout_margin:
Space outside the view between itself and its container is called margin.

android:layout_padding:

Space inside the view between its boundaries and content is called padding.

__________________________________________________________________________

18- Google Analytics integration in android app:

Google Analytics integration in android app:
https://developers.google.com/analytics/devguides/collection/android/v4/ 

Interview Questions - Asked by different companies


TechnoSoft Solutions



  1. FYP
  2. WCF services
  3. How to secure WCF?
  4. What is Web services?
  5. Abstract classes and interfaces (if we have 4 abstract methods. what is good? why we need two different approach. If I don't need multiple inheritance)
  6. Abstraction (How it difference from C string library. In which we also call methods)
  7. Difference between abstraction and encapsulation?
  8. HTML table code (first columns were merge)
  9. Find sum of max and second max in an array?
  10. Join (inner or outer)
  11. How garbage collector call and works?
  12. Session handling in back-end
  13. Strong points of yours
  14. Weak points of yours
  15. .net latest versions (.net, mvc, asp)
  16. Unsafe code?
  17. CLR
  18. JIT
  19. data types in C#
  20. difference between primitive and reference type
  21. float size
  22. decimal size
  23. yield keyword in C#
  24. usafe code in C#
  25. how to prevent class for inherit further
  26. LINQ query
  27. WCF services
  28. array sort method use which algorithm
  29. Data validation through data annotation
  30. how to apply password match data annotation
  31. Asyncronious call
  32. data annotaion library name
  33. Linq query for joins
  34. IEnumeriable and Iqueryable
  35. Task class in C#
  36. viewBag, ViewData, TempData
  37. LifeCycle of tempData
  38. seed in entity framework
  39. join (left or right)
  40. code first approach function name
  41. jQuery selector
  42. two linked list intersect each other find point of intersection
  43. find loop in linked list
  44. 31 * 29 in mind
  45. a frog fell into well, well has 30 stairs. He daily climb 4 stairs and fall 3 stairs. How many days he came out of well
  46. Lahore to Karachi 20 telephone exchange one telephone exchange is damage find damage telephone exchange
  47. can wcf service have different type of end points
  48. in a from if the student select he is graduating than institute field become required through data annotation?
  49. database schema(folder has folders + files and so on)
__________________________________________________________________________

Northbay Solutions



  1. encapsulation
  2. Composition & Aggregation ?
  3. abstraction
  4. abstract classes vs interfaces
  5. can we use access identifier in interface?
  6. overloading and overriding
  7. there is another overloading which is? (operator overloading)
  8. what is operator overloading?
  9. deep copy/shallow copy
  10. when content of an object change in deep copy does other also change?
  11. All sorting algorithms & When to use which ?
  12. Best sorting algorithm?
  13. time complexity of best case of bubble sort?
  14. which sorting algo is best in average case?
  15. what is meant by space complexity?
  16. database optimization (how many steps? usually we go through how many steps?)
  17. advantages and disadvantages of normalization?
  18. relational algebra in db?
  19. Context Switching?
  20. paging
  21. deadlock conditions
  22. two ropes problem. one rope burn in 60 minutes calculate 45 minutes from 2 ropes?
  23. Divide cube into 8 pieces with 3 cuts?
  24. produce 0,1,2,3,4,5,6,7 from rand5() function. each number should have equal probability?
  25. input: My name is Furqan.
  26. output: Furqan is name my.  (write program)
  27. FYP
__________________________________________________________________________

Rolustech Dynamic IT Solution


  1. composition vs aggregation vs association 
  2. static binding, dynamic binding
  3. overloading, overriding
  4. static variable
  5. abstract classes vs interfaces
  6. what is necessary for a class who implements interface 
  7. swap two variables without using anyother variable
  8. find second maximum from an array
  9. database join query
  10. Android:
  11. FYP
  12. activity vs fragment
  13. list View
  14. adapter
  15. layouts
  16. web services
  17. intent