Overriding and Overloading: What’s the Difference?

Share if the site was helpful

Overriding and Overloading: What’s the Difference?

When programming for Android (or anything) writing custom methods isn’t optional. If you don’t know what it means to write a method, then I recommend you check out Phonlab’s video tutorials.  And if you do, then don’t tune out yet!  Methods are like icebergs (90% of their functionality is unseen at first glimpse).  And getting to know the other 90% is what can take you to the next level in your development.  In this post we’re going to explore the ins and outs of overriding and overloading to make development easier.

Methods 101:

If you’re an Android programmer, then you undoubtedly know what a method is.  It’s a block of code that you give a name.  This way every time you call it that block is executed.  I know it’s a fundamental concept of programming, but here’s a sample that we’ll build onto over time.  Let’s say that you’re building a contacts app and can add contacts given a name and phone number.  Here’s the class your app uses:

Great, seems simple enough right?  But any good contacts app is going to do more than just this.  If a user wants, they should be allowed to include other info as well.  What if they want to put one contact on speed dial? Or what if they want to add a contact to a group?  How about this:

Now, there’s no problem with this code.  Each of these three methods will add a contact with the extra information that they included.  But these method names could start turning ugly if we kept adding parameters.  How do you feel about the method name addNewContactWithSpeedDialAndGroupAndPictureAndAgeAndRingtone?  First off, I’d say let’s drop every “And”, but even so that method name is getting long.  This is where overloading can help.

Overloading:

Overloading is the practice of creating new methods with the same name.  But you can’t have two identical method names, right?  If they had different logic how would the computer know which one to execute? Well they actually can as long as the parameters are different.  As long as your methods each differ like this:

then the compiler is able to recognize them each as individual methods.  So now if a user wants to add a contact it doesn’t matter how much information they give!  They can either call addNewContact(Carl, “1112223333”) or addNewContact(“Carl”, 1112223333, “Friends”) and their new contact will be added with that info.

Order counts too, you could have the methods addNewContact(String name, int phoneNumber) and addNewContact(int phoneNumber, String name) as two separate methods in the same class.  This doesn’t open many doors in this specific scenario, but it’s handy to know all the same.

Overriding:

While it sounds almost identical, overriding a method is a somewhat different technique.  This allows us to take a method that exists in a parent class and change its behavior.  As a demonstration let’s say that our contacts app has a page where you can look at individual groups.  When you open the group for “Family” there is a button where you can add contacts to this group.

Our new class named FamilyGroup will extend our NewContact class.  By doing so it now has access to the parent class’ methods.  But we don’t want our user to have to type in the group they are going to use.  That’s a waste of time for them since they’re already in “Family”.  To fix this we’ll override our addNewContact(int phoneNumber, String name) like so:

Now when a user puts in info for a new contact’s name and phone number this method will call NewContact’s addNewContact(int phoneNumber, String name, String group) and pass in “Family” for the group.  Sure, we could have written another function in this class to add the contact, but this way no matter how complicated NewContact’s method is, we get to call it again with only one line of code!

Wrapping up:

Overriding and overloading can make your code a lot neater if used properly, and there’s a tone of cool things you can do with these techniques in the real world.  This contacts app isn’t the most realistic project, but it gets the simple idea across.  When you start getting into more complex inheritance overriding can save you a ton of space.

If you enjoyed this post at all and want to learn more about Android development check out some of our other tutorials such as how to develop augmented reality or more complex apps!

 

Duplex Makes its Debut

Share if the site was helpful

Duplex Makes its Debut

At Google I/O 2018 we saw a breathtaking performance on the center stage.  The world watched as Google Assistant placed a call to a hair salon and booked an appointment.  This new feature known as Duplex has been marketed as your new secretary, but unfortunately up until  now it’s just been an exciting video to watch.  Things are changing though, and Pixel 3’s are about to start seeing Duplex roll out onto their phones.

Duplex:

From a 3rd party view what was so amazing was how lifelike the conversation appeared.  Though the conversation took place between a computer and a real person, it was borderline impossible to tell which was which.  Google Assistant dialed the company’s phone number and then conversed with a receptionist on the other side.  It even went as far as to throw in lifelike “mhmm”’s. 

This was the first peek into Duplex, and since then we’ve seen the Pixel 3 elaborate on the release.  The newest flagship phone users have the option to avoid calls from unknown numbers.  They leave the dirty work of figuring out who is calling to Duplex which talks to callers and displays a transcript of the conversation to users.  The beauty of this is that you’ll never have to talk to a telemarketer again!

The Rollout begins:

Duplex has been big talk recently but that’s been it.  Now Google has announced it’s rolling out the feature to a select number of Pixel owners in select cities.  If you own a pixel and live in Atlanta, New York, Phoenix, or San Francisco then you’ll get to be one of the first beta testers.  As a Pixel 3 owner myself I’m waiting eagerly for the next wave, but it’s good to know progress is being made.

As expected there are initial limitations on the feature such as it only being able to make calls in English.  People using Duplex will be able to use it with commands as simple as “Hey Google, make a restaurant reservation”.  Yes, it would help to specify where, but the concept is that you have to do next to nothing!

Opting Out:

Google has also said that businesses can opt out of the service by toggling an option in their Google My Business account.  Or if a business answers the phone and says, “I don’t want to be recorded” (or something similar) they are opted out.  It seems Google is preparing for the inevitable backlash from businesses and people who don’t want any part of the system.

What are your thoughts on Duplex rolling out to Pixel phones?  Are you counting down the days until you can use it too?  Let us know in the comments below.

Smartphone features lost over the years

Share if the site was helpful

Smartphone features lost over the years

Of all the things in this world, smartphones are one of the most used devices in the world and have seen many changes over the past few years. Only in about 5 years, smartphones went from being only 4 to 5 inches in dimensions to 6 to 7 inches. Furthermore, the OS and other features in these phones have seen drastic changes. Although not all of these changing features have been well-loved and appreciated, there are many other features that we have come to love and use every day.

The various developments and changing scenarios in the smartphone world have not only given us competent phones, but dual cameras, a huge hit with the smartphone using generation, and better batteries. However, when we talk about smartphones, it hasn’t always been merry.

With better phones and better features, we pay the price of losing certain features. Losing the headphone jack in our beloved smartphones has been one of the most recent laments of the smartphone using generation. And it is safe to say that it wasn’t the first, and surely will not be the last.

 

Smartphone features lost over the years that we really loved

Smartphones come with various features and immense power. However, when any company takes their smartphones to the next level, there is always something or the other that gets left behind. Every day smartphone giants chop off some feature or another that they deem useless. Here is a look at the smartphone features that we loved and the lost over the years:

 

No more removable batteries

Somewhere around in 2015, the trend shifted from smartphones with removable batteries to smartphones with non-removable batteries. iPhone was the first ever smartphone to be released with a non-removable battery in 2007. However, over the years, to slim down the phones and to offer a better build to the phone, many companies began to manufacture phones with a non-removable battery.

Surely we love slim phones, but we also loved the fact that we did not have to discard our phones when the batteries began to malfunction and give us a bad output. In today’s time, even if you love your phone dearly, you will have to choose another phone if your phone’s battery does not work properly.

 

No FM Transmitters

Yeah, the world has moved on, and we now have Google Music and Apple Music, even YouTube to help us play the music that we want. However, to all of those people who love nothing better than to listen to the music on air or enjoy a classy session of FM, sadly there is no helping them. With only our cars with FM transmitters, there is hardly any place for FM lovers to hear what they like. Gone are the days when you could plug in your earplugs and blast your favourite FM channel on your smartphone.

 

Physical Keyboards and Trackball

Remember the time when BlackBerry took the world over a storm and enjoyed the popularity that Apple enjoys today? Well, if you do, then you probably know that the best of BlackBerry’s days came with its amazing physical Qwerty keyboard. Although the advent of smartphones did not directly let go of the Qwerty and trackball features, the trend did die down after a while. Furthermore, smartphones like the Motorola Droid, the T-Mobile G1/G2, Sprint Epic 4G Touch tried to keep the Qwerty fever alive, but it did not work out so well.

 

We know that BlackBerry KEYone still exists, but honestly, the phone does not gel with the requirements of today’s time. The phone is nothing but a low-powered phone which will obviously not allow you to do anything.

 

Slideout designs: Best of Smartphones

Before we had iPhone to set the parameters for the best features to look for in a smartphone, Nokia used to make various kinds of strides in that department. The best feature of Nokia phones were the slideout designs. Surely, Samsung was one of the companies that offered good phones with slideout designs, but nobody did it better than Nokia. During that time, somewhere in early 2007, the companies were battling it out creating flip phones with revolving screens, slideouts in two different directions as seen in N9 or a phone that slid open to show the keyboard as seen in Nokia N900, there was no shortage of fun phones to find.

However, with everything becoming an on-screen game these days, it is hard to find a smartphone that comes with a Qwerty keyboard or with slideouts. These features were taken away from smartphones to create a slimmer and better smartphone. But not to fear, as while sliding is out, foldable smartphones may soon be a reality with innovations from Samsung.

 

The Issue of Losing the Headphone Jack


Yes, we know, that the headphone jack is still present on many phones, but the number is dwindling. However, when you look at it closely, there is a number of companies that have already decided to omit the jack from their system. The point is that creating space for a headphone jack takes up space that could be used for other things like beefing up the battery. Furthermore, the new trend of Type-C USB has also led to a decline in the use of headphone jacks in the phones. The Type-C USB is made for only one purpose, and that is to offer you one cable for all kinds of uses.

Although you can still find many kinds of smartphones with headphone jacks, there is a possibility that very soon we would lose the headphone jack. Apple and HTC have already taken the steps of removing the headphone jacks, and it is only a matter of time Samsung, and other companies follow suit.

Surely, we have seen many impressive phones over the past few years, but nothing can beat the features that we have lost over the years, especially the uniqueness that each phone had in the market.

Which feature do you miss please comment below.

 

Unbelievable features on todays flagships

Share if the site was helpful

Unbelievable features on todays flagships

If you head over into your wardrobe and dish out your old favorite smartphone or feature phone you’ll realize that while the basic premise of what makes a phone tick is same (processor, RAM, display and battery), a lot of features have seen massive upgrades. Displays on today’s smartphones are much larger and higher resolution than before, processors can now process a lot more tasks including AI! which manufactures brag about at length and camera sensors have for the first time made it possible for us to leave our bulky cameras and video cameras at home.

 

But despite the huge numbers of smartphones in the market, there are a lot of similarities amongst most of them. But, today we are going to look at some unique features in flagship smartphones.

 

Sliding cameras:

It’s no secret that a lot of people hate notches on their phones, but the reason for the existence of notches was that it wasn’t possible to place camera sensors under the display along with the sensors. But over time we have managed to make ultrasonic sensors and in-display fingerprint scanners but the cameras still take up considerable space and that’s why we have notches. But Chinese smartphone makers Oppo and Vivo have come up with nearly bezel less phones with sliding/ pop-up cameras. While Vivo’s approach is more simple and thoughtful putting only the front camera on the slider, Oppo went all out, putting both the front and rear cameras on the slider. But these are not all, the upcoming Honor Magic 2 and Mi Mix 3 are rumored to have something similar with manual sliders.

 

Multiple cameras

For a long time smartphones were considered inferior to standalone cameras and while the current generation hasn’t surpassed DSLR’s they have certainly come very close. But with people’s obsession with shallow depth of field effects of the DSLR meant smartphones makers had to mimic the same on phones. But with the size of the camera sensor being tiny on phones you’ll need a very wide lens so a secondary sensor is used to get the depth effect. Manufacturers often go berserk when a new feature or trend is created, the same is with multiple cameras. A few of the latest phones have up to 5 cameras on their phones like what LG did with the V40 ThinQ (appalling name, we get it). The ThinQ gets a 12 MPx primary sensor at the back along with a 107 degrees wide-angle sensor and a 50mm equivalent zoom sensor. The story is similar at the front as well with an 8Mpx primary sensor and a 5 MPx wide angle shooter. There are only a handful more phones that use these many sensors like the Huawei P20 Pro which was amongst the first ones to start this trend of triple rear sensors.

 

But hold on if you though three rear facing camera sensors are a lot, look at the world’s first quad rear camera phone, the Samsung A9 with four rear cameras (Mian camera, Wide angle, zoom and depth)

 

High refresh rate display

Razer debuted its first gaming phone the Razer phone almost a year ago and while it wasn’t a standout in terms of design there was one feature that not a single phone in the market at that time (and even today) possessed- a 120Hz refresh rate display. A high refresh rate display is common in gaming monitors that go all the way to 144 Hz and more but what’s the use of it you may ask? Well, for gaming it means a far smoother game play, on your phone you can expect silky smooth animations and ultra smooth scrolling and app openings. Not just that the phone can dynamically adjust the refresh rate so as to conserve power during tasks like reading a web page where it can dial down all the way down to 20Hz.

 

Holographic display

Displays have improved over the years in terms of brightness, resolution, colors, viewing and more but there are few that have had something revolutionary. Way back in 2011 there were a couple of 3D display phones but the technology never caught on and most of them were shelved. But recently iconic camera manufacturer, Red decided to make a smartphone (The Red Hydrogen One) for movie makers that would pack a ton of kit from ergonomic design, high-end cameras, pogo pins for Moto Mods like attachments and a Holographic display. The Holographic display is what caught the fancy of many as it lets you watch 3D content without 3D glasses. From the few people who have had access to private demos of the phones describe it as something similar to R2-D2 projecting an image. While it sounds cool and almost science fiction like, how effective it is only time will tell.

 

Quad DAC and Headphone jack

2018 has been the year when most flagship phones ditched the age-old headphone jack for wireless and wired USB-c connectivity. Apple iPhone, the next generation OnePlus, Razer phone, Pixel 3 all lose out on the headphone jack but one manufacturer is firm about its commitment to the headphone jack and high-quality audio- LG. Long been a favorite of the audiophile community the LG flagship phones come with an excellent 32-bit Hi-Fi Quad DAC (balanced sound signature) with the Stereo Boombox Speaker with DTS:X 3D Surround Sound. Also, this time around the sound is tuned by Meridian Audio This makes it one of the few truly capable phones for great audio quality.

 

Super fast charging

OPPO Find X Automobile Lamborghini Edition is a limited edition version of the Oppo Find X and while it has the usual limited edition features like a high price tag, exotic materials and a lot of accessories, there is one really cool feature that is pretty unbelievable-Super VOOC Flash Charge. Building upon the VOOC charging in current Oppo phones the Super VOOC technology uses a 50W charger and two batteries to deliver an unbelievable charger rate. Taking around 35 minutes to juice up the 3400mAH from dead the Super VOOC is undoubtedly the fastest smartphone charging standard in the world.

 

Reversible wireless charging

While wireless charging is a common feature on most flagships, the Huawei Mate 20 Pro launched recently takes that feature a step forward with something called reversible wireless charging. With this, you can use you Mate 20 Pro to charge your mates iPhone or other devices that can be wireless charged. Despite your phone’s battery being drained, you don’t have to worry as the battery is a large 4200mAh unit which can be charged up to 70% in only 30 minutes.  

 

These are some of the standout features, especially in today’s smartphones. There are still many phones out there with quirky features like the Note 9’s super capacitor powered stylus or the Moto Mods on the Moto Z lineup of phones and more. While phones of today are not as quirky as the phones of yester years, we do occasionally get something with unbelievable features. So, what are the unbelievable features you came across on a smartphone? Do let us know in the comments below.

Android Isn’t Going Anywhere

Share if the site was helpful

Android Isn’t Going Anywhere

There’s been a buzz going around this week that Android is dead.  Well dying actually, but everyone is claiming that Android’s reign is coming to an end and Google is moving forward.  If we take a few moments to look at the bigger picture then we’ll see Android has a long way to go before it’s no more.  The most popular operating system in the world is here to stay for a long time.

The Rumor:

The rumors pertain to the Made by Google 2018 keynote that just took place in New York City.  During this keynote the word “Android” was not said, and many have taken this as a subtle sign that Google is looking to replace the brand.  This coupled with the fact that “Android Messages” was recently renamed to “Messages” on the Play Store, and bloggers everywhere ate it up. 

Many believe that Chrome OS is set to take over Android’s claim as king since that was front and center at the keynote.  Google told a whole story about Chrome OS’s history and why it belongs on tablets. They also marketed it as a great alternative for your desktop instead of Windows and macOS.

Do the rumors stand?

While it may be true that we didn’t hear the word “Android” explicitly said, let’s not forget that there is still Android related tech coming out.  Android Auto is rolling out to a ton of new cars this year, Android Pie was released at the start of this fall, and Google just adopted Kotlin as a new official Android programming language.

Along with all these new developments we have the Google Pixel 3 and 3 XL that have just come out running Android Pie.  Sure they would have to run it since that’s the newest version to come out and it’s Google’s flagship phone.  But let’s remember that that’s the newest version to come out and it’s Google’s flagship phone.  People are discussing the death of Android less than a week after a new huge phone dropped running that same software.

Looking Forwards

Sure there are things in the works to improve the user’s experience like Fuschia, but that doesn’t mean that Android is on its way out.  The fact of the matter is Android is going nowhere.  An operating system that covers 75% of smartphones worldwide is too nested into Google’s overarching architecture to instantly remove, and there are too many new Android advancements coming out to argue that Google wants to remove it.

What do you think about the recent talk against Android?  Let us know your predictions in the comments below!

 

The Pixel 3 has been unveiled, and it looks sweet!

Share if the site was helpful

The Pixel 3 has been unveiled, and it looks sweet!

We’ve talked about the Pixel 3 again and again here at RootJunky, and there have been far too many rumors and leaks about it over the past few months.  I’m happy to say that’s all come to a close.  Not because I don’t like writing about it, but because the Pixel 3 has officially been released. Earlier today Google unveiled the new phone, and the preorders have begun rolling in.

The Hype Recap:

Before we get in to what the Pixel 3 and 3XL actually are, let’s take a second to remember how much build up there was about these devices.  There were images leaked on the XDADeveloper forum showing a notched display with two cameras, as well as a glass back for wireless charging.  But hardware leaks aside, what was really interesting about this phone’s build up was the rumors about rumors.

After we’d all sat with the leaked images for a bit the news surfaces that Google was reaching out to popular YouTuber’s asking to use their clips bashing the leaked design.  The result of this was the people began thinking Google had intentionally leaked images so that they could use this footage in their grand reveal of a more impressive phone.  It was a conspiracy theory for sure, but not entirely unbelievable.

Fast-forward to October 9th’s Hardware:

Skipping to today the Pixel actually dropped, and it actually doesn’t look that different from the leaked images.  Despite what some YouTuber’s may have said I don’t think that’s a bad thing.  Starting at $799, the Pixel 3 sticks to the traditional design of a split material back allowing for wireless charging (thank goodness!).  The regular phone measures in at 5.5 inches and for $100 more the XL measures in at 6.3 inches.

Pixel phones have been notorious for having great cameras, and that trend isn’t stopping with the Pixel 3. It is however deciding to avoid the current trend of a dual rear camera.  With a total of 3 cameras, one can be found on the back and two on the front.  And guess what?  For the XL these cameras are nested in a notch.  This trend seems to be sticking around for a while, and even Google’s flagship device has embraced it.  The new cameras seek to take the crown and offer incredible zoom in as well as a wide range selfie mode.

Screening the Spammers:

Remember that ground breaking release from Google I/O earlier this year called Duplex?  It seemed unreal as the Google Assistant called a barber shop, had a conversation with the receptionist, and successfully booked an appointment for its user.
Well the Pixel 3 leverages this technology to make your call screening much more enjoyable.  Using Duplex, you’ll never have to answer the phone for a telemarketer again.

The Pixel 3 can answer itself and provide a real-time transcript to you of whatever the caller says. Duplex prompts them on the other side of the line asking them to identify themselves and let you know if the call is urgent, and as they talk you can see the text appear on your screen.
Then if you want to answer you can, or you can select from premade responses to keep the conversation going and get more details before deciding to pick up or not.  Google Assistant really is becoming a personal secretary.

I’m really excited for the Pixel 3 to be out and will be getting my hands on it as soon as I can. What are your thoughts on the new device?  Let us know in the comments below!

 

 

 

 

 

 

 

Google Minus And Project Strobe

Share if the site was helpful

Google Minus and Project Strobe

After 7 years of effort Google has decided that enough is enough for Google+.  The tech giant has admitted to failing its entrance into the social media marketplace. As both a business decision and safety concern they’ve decided to take Google+ off the web and focus on other things.

Project Strobe

Security has been at the forefront of everyone’s minds this year as privacy scandal after privacy scandal has surfaced.  Facebook’s Cambridge Analytics scandal made us hyper aware of how much data is exposed to third-parties.  In an attempt to combat privacy issues Google launched Project Strobe.  It’s a root-and-branch review of third-party developer access to Google accounts and Android devices.  Essentially it’s a research project to check up on how secure everyone’s information really is.

The findings: not the best.   Today Google announced four key findings from the project along with steps to remedy each.

1. There are significant challenges in creating and maintain a successful Google+ product that meets consumer’s expectations.

Google+ has a pretty serious bug in it that exposed user data to third-party applications that didn’t have proper access.  Google says that there is no evidence anyone else found this out before they did (hard to be sure).  But combining this with the lack of adoption among users and the end result has been to remove Google+ entirely.  I don’t think anyone is too upset at this move, and it’s probably for the best Google diverts its time towards new innovations.

2. People want fine-grained controls over the data they share with apps

When you download a new app that performs certain functions, it may need permission to do so.  Whether that’s accessing your camera to take a picture or seeing your contacts so that it can share a picture with others, apps can’t do these things until you let them.  This is a big plus for Android security, but unfortunately sometimes it’s not organized well enough.

There are some permissions that are grouped together when presented to a user, and this can potentially be a problem.  If you want an app to do one thing you shouldn’t have to grant it access to 3 permission, yet this is sometimes how things are organized.  Google has announced they’ll be launching more granular account permissions that will show individual dialog boxes for each.  Maybe a little more frustrating for relaxed users, but definitely a win for security.

3. When users grant apps access to their Gmail, they do so with certain user cases in mind

To correct the security issue of third-parties abusing contact information Google is limiting what kinds of apps are allowed to access Gmail data.  The only apps allowed will be those that are “directly enhancing email functionality”.  Basically, if there’s not real reason for your app to need to write an email, it’s banned.

4. When users grant SMS, Contacts and Phone permissions to Android apps they do so with certain use cases in mind.

3 and 4 are pretty similar to one another, but this other finding takes things past email and into the phone/contacts.  Google is limiting how many apps will be allowed to access this information.  In addition to this Contact interaction data will no longer be available vie the Android Contacts API.

The bottom line is that Google did a security sweep and decided a few things needed to change.  It seems that these changes are proactive which is always a good things, but if you’re one of the world’s Google+ user’s then I’m sorry you have to say goodbye.  For everyone else these changes should be nothing but good as security continues to improve.

What are your thoughts on Project Strobe?  Let us know in the comments below!

 

Let Firebase Cover the Basics For You

Share if the site was helpful

Let Firebase Cover the Basics For You

When it comes to writing code, the less you have to do the better.  You want control over how your applications behave, but if you can piggy back off of other developer’s work then that’s generally a good thing.  And if you’re hoping to be an app developer, then one of the best tools for piggy backing is Firebase.

Using others to your advantage:

If you think about it even developing the most basic app takes the work of countless others.  Someone else had to develop the programming language you’re writing in, someone else had to build the IDE (probable Android Studio) that you’re developing on, and someone had to…well you get the point.  Any modern-day invention was not created from nothing, it came about thanks to the ground work being done by something that came first.

This doesn’t mean you can’t be innovative.  It means that there’s nothing wrong with using 3rd party libraries and tools to make your development journey easier.  If you don’t have to worry about the basics then you can focus on what makes your app great.  Ok enough justification, let’s talk about how you should use Firebase to make life easier.

Authentication and Data Management:

How many apps do you have that require you to sign in to fully use features?  Of those how many let you create and account through Facebook?  Users hate having to create sign-in info, a decent percentage won’t even go through the process because of the extra 10 seconds it takes.  So including an option for one-click sign in makes it more likely your app will succeed from the start.  Firebase makes this feature easy to leverage allowing you to create a sign in screen with companies like Facebook, Twitter, and Google. 

When users sign up Firebase keeps track of their info and allows user management to be easily configured.  If a user gets a new phone they can log in and Firebase will associate them with the same account.  Firebase also has a database feature allowing you to create and store JSON info, so users can interact with one another and store information easily.  Let’s say you wanted to create that new social media app which lets people post pictures and message one another:  Firebase should be your go to.

Analytics:

When you release an app it’s best to have a game plan for what’s next.  What if users love one part of the app but never use another?  Well if that’s the case then you should aim for a redesign that either brings in new features or directs the users attention to things they are more interested in.  Of course if you release an app and people in other countries start downloading it you can’t exactly track them down and ask them how they’ve been using the app.

This is where analytics come in.  Firebase gives you the capability to monitor user events (anonymously) so you can see which features are getting the most interaction.  If you have a search bar in your app that no one ever clicks on, it’s either time to drop it or move it elsewhere to try again.  Analytics can keep you in know for how your app is behaving and what should change.

Crashlytics:

And on the topic of what should change in app behavior, crashes are about the worst thing a user can experience.  You may be getting 1 star ratings in the app store because your app shuts off randomly for some users and you don’t know why.  Firebase offers Crashlytics to look at the stack trace details for every crashed application.  If there’s one button in your app that is broken and slipped through your checks when publishing, now you’ll be able to see that it’s responsible for the crashes and act accordingly.

Firebase offers a ton of other features that can make development easier and the user experience more fluid.  These are just the tip of the iceberg and features I enjoy using on a daily basis.  If you want to learn how to incorporate Firebase into your apps then checkout Phonlab’s Android Development Course!

 

That Missing Guide To Kotlin Part 2

Share if the site was helpful

That Missing Guide To Kotlin Part 2

In part one of our Kotlin series we began exploring the newly adopted language.  We saw a few examples of how it can make our code more concise and user friendly than Java including type inference and inline constructors.  In part two we’ll continue to show how Kotlin can make your code easier to work with while focusing on one dreaded Java roadblock: The NullPointerException.

If you’ve written anything in Java before then you’re familiar with NPE’s.  It occurs when you attempt to interact with a variable’s value, but it turns out there is no value to interact with.  Your compiler can’t see that there’s no value available, but at run-time your system checks for it and then crashes when it can’t be found.

Kotlin to the rescue

While Kotlin is 100% interoperable with Java (99% really as we’ll see soon) it’s fundamentally different in a few aspects.  One of these is nullability.  In Java every variable has a default value.  This is the value it can fall back on if you never explicity say what value it contained.  For example when you declare a boolean variable, unless you specify its value, it will be false.  For any variable that isn’t a primitive type, the default value will be null.  This can be really useful at times, but it allows us to accidentally try to grab a value when there isn’t one.

In Kotlin its possible to completely avoid this situation. Every variable that is declared is either a nullable type or a non-null type.  What this means is that along with declaring what type of value (Int, Boolean, custom class) your variable holds, you declare whether it is ever allowed to be null or not.  Here are two varaibles declared in Kotlin.  The first can never be null, while the second is nullable.

As you can see, the question mark is used to show a variable has the possibility of being null.  If there’s no question mark in the variables declaration, then you are safe to use it in every situation without risking it throwing an NPE.  This means that you’ll never have to write if statements checking if a variable is null to play things safe. Goodbye useless lines of code

Nullablility In Action

When using non-null type variables, we don’t have to check if there is a value present.  But for other situations we still must take precautions.  One way that Kotlin allows us to do this concisely is through safe calls.  A safe call looks similar to the traditional method of retrieving a value, except we include a question mark at the end of the variable.  So

Becomes

By doing this we can almost read the code as if it’s English.  We’re asking “does the pet exist?”, and if the answer to that question is yes then we move on to the name characteristic of our pet.  If there is no pet that has been created at this point in our code, instead of the app crashing our variable will be given a value of null.

This becomes incredibly powerful when we start chaining safe calls.  Let’s say we want to check if a company has an HR department with an employee name Toby who at tuna for lunch.  Instead of writing a null check for each of these before interacting with them we can write

If along the way any of these things doesn’t exist, then the code will finish the statement returning null and not interacting with any of the variables past the break.  Without an HR department the code won’t crash, but instead our employee variable will be set equal to null.

Control Is A Good Thing

This is probably the most common feature of Kotlin that you see people talk about, and it’s because of how powerful it is.  Not having to deal with null values is amazing, but even when we have to our code can be concise and clean.

The language can also smart cast nullable variables into non-null given the proper verification at first.  So if you had a nullable variable and then explicitly check if it wasn’t null, then you wouldn’t need to use any ?’s moving forward when accessing that variable.

Kotlin isn’t perfect, but when it comes to dealing with null values it has everything that Java has to offer with some additional perks and changes.  We’ll continue exploring some of Kotlin’s advantages in part 3.  In the mean time if you have any questions about how nullability works let us know in the comments below!

Rumors About Rumors About the Pixel 3

Share if the site was helpful

Rumors About Rumors About the Pixel 3

Over the past few months rumors have been floating around left and right about the upcoming Pixel 3 and Pixel 3 XL.  We’ve written about leaks here before as a serious of photos have surfaced revelaing potential designs.  Of particular interest are the XL leaks with the notch taking phone manufacturers by storm these days.  These are so interesting not because of what they show, but what they may be hiding.

The newest rumor going around is that the Pixel 3 XL we’ve seen thus far is a fake.  And not simply fake that someone decided to make up, but rather a fake that was released by Google to throw people off.  It’s a bold claim, but not entirely impossible.  Here’s why:

Hating The Notch:

When the XL leaks first surfaced a lot of people got excited.  And likewise a lot of people were upset to see that the notch was involved.  The 3 is set to bring back other exciting features like wireless charging, yet the notch seems to be what gained so much attention.  Some well known YouTubers have critiqued the design on their channels.  Google has taken note.

According to Jon Prosser, one of the YouTubers who spoke out against the leak, Google reached out to him and asked for a very specific clip of him speaking badly about the design.  He found out from other YouTubers that the same request was made to quite a few of them.  Google didn’t say why it wanted the footage, but simply asked for it.

What’s Google’s Game?

So why would Google want to use footage from well known reviewers bashing its product?  Well, the natural conclusion is that it’s not really their product.  If people hate the design that’s been leaked and it turns out that’s not actually the desing Google is unveiling in October, then no harm no foul.  Actually if anything it could help Google as they market that they’ve listened to people’s feedback and are moving in a direction that consumers want.

It’s possible (but not confirmed) that Google has artificially leaked things in an attempt to generate a buzz about the new phones.  If that’s the case then it’s definitely worked.  As to the probability of this actually ocurring…well that’s another story.  Only time will tell, but you could argue it’s pretty farfetched.  It would be incredibly hard to keep this kind of fake leak in house up until now.

Pie and The Notch

The Pixel 3 will also be the first phone to come with Android Pie which includes notch support.  The two don’t have to come in a package deal, but it would be a little strange to see that as a feature in Pie and not have it avaiable to users who buy the first phone with it.

What do you think of these rumors about rumors?  Whether you think its plausible or ridiculous let us know in the comments below!

 

 

en English
X