Skip to main content

Posts

Showing posts from September, 2020

Firebase FireStore

  Firestore is a subset of Firebase-Real-Time Database Firestore is a NOSQL Cloud Database which is extremely,customizable,efficient and scalable. Unlike SQL,we don't need to specify the column name and entity before putting the data in the table rather in NOSQL we don't need to predefined the structure of the database. In case of NOSQL, Database is called collection and Tables are called Documents. Documents allow us to add key-value pair which is basically the json format because json is easy to manipulate,query and very flexible. We can add documents inside the collection by specifing its name otherwise firebase we create an id for it. SetUp: 1) Inside Android Studio,go to tools select Firebase. 2) CLick on Log an Analytics event below the Analytics. 3) You will be redirected to login with your google account. 4) Log In into your account. 5) Go back to Studio you will that the Connected will be written with checked sign. 6) Now click on Add Analytics to your app.Now android ...

Handler in Android

  A Handler is an Android class you can use to schedule code that should be run at some point in the future. You can also use it to post code that needs to run on a different thread. To use the Handler, you wrap the code you wish to schedule in a Runnable object, and then use the Handler post() and postDelayed() methods to specify when you want the code to run. Before diving deep inside the Handler we must study about the Runnable. A Runnable is a job you want to run.The code that we want to run in Runnable is put inside the run() method of runnable. Handler Methods: 1) post() method: This method posts code that need to be run ASAP(almost immediately).This methid takes only one parameter,an object of type Runnable. final Handler handler=new Handler(); handler.post(Runnable); 2)postDelayed() method: This method does its work in a similar way to post() method except we use it to post the code that should be run in future not immediately. This method takes two parameter.One is Runnabl...

Dealing with configuration changes

  How to deal with device configuration changes such as change to the screen rotation? Because whenever there is change in device configuration the activity gets destroyed and re-created,which meant that local variables used by the activity were lost. There are two options: we can either tell Android to bypass restarting the activity, or we can save its current state so that the activity can re-create itself in the same state. 1) Bypass re-creating the activity We can tell the android not to restart the activity if there's been a configuration change.Usually it's not the best option.This is because when Android re-creates the activity, it makes sure it uses the right resources for the new configuration. If you bypass this, you may have to write a bunch of extra code to deal with the new configuration yourself. We can add some line of code in activity element in AndroidManifest.xml Example: <activity android:configChanges="orientation|screenSize" > Here we...

Creating Chooser for Intents

  There's a way around you can create your own chooser that asks you to pick an activity without asking if you always want to use it. This task can be acheived using 'Intent.createChooser()'. Intent.createChooser() allows you to specify a title for the chooser dialog, and doesn’t give the user the option of selecting an activity to use by default. It also lets the user know if there are no matching activities by displaying a message. Syntax: Intent chosenIntent = Intent.createChooser(intent, "Send message..."); intent is the original Intent that we have made which describe the types of activity you want the chooser to display. "Send message..." here specifies the title of the activity chooser. The createChooser() method returns a brand-new Intent. What happens in the background: 1) The createChooser() method gets called. The method includes an intent that specifies the action and MIME type that’s required. 2)Android create a chooser for activities that ...

Intent Filter

  When Android is given an intent, it has to figure out which activity, or activities, are able to handle it. This process is known as intent resolution. When the intent is explicit, the intent resolution easily figures out which component the intent is directed at. But when we use an implicit intent.Android uses the information in the intent to figure out which components are able to receive it. It does this by checking the intent filters in every app’s copy of AndroidManifest.xml. An intent filter specifies what types of intent each component can receive. Example: <activity android:name="ShareActivity"> <intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="text/plain"/> <data android:mimeType="image/*"/> </intent-filter> </activity> Here’s the ent...

Flutter vs Native App Development

  Building a cross-platform app is a tedious process. As usual google comes to rescue.Google has launched Flutter,a framework that can be used to build both android and iOS apps. So What is Flutter? Flutter is an open-source,mobile development framework developed by Google which uses single code-base to build apps for both android and iOS so we need not to maintain two code base seperately for android and iOS. It used Dart as the programming language which was developed by Google(designed by Lars Bak and Kasper Lund).It can also be used to work with web,server and some IoT devices.It is quite easy to learn specially for Java developer as the syntex is somewhat similar to Java. Dart was developed with common developer tasks in mind and solving the problem the were faced by the developer when they were using the Java,Kotlin or any other language. Features of Flutter 1) High Quality native interface: Flutter is loaded with large number of widgets which can be easily used to construct ...