Now you can Subscribe using RSS

Submit your Email

Sunday

RecyclerView with GridLayoutManager Android Example

Vishal Shrestha
Today we will be making a Grid View like list using a RecyclerView with GridLayoutManager as shown in the Video below, but let's first talk a little bit about recyclerView; as you might already know a RecyclerView is more advanced, flexible and efficient version of a ListView. If you have large datasets, you should work with RecyclerView instead of ListView for better efficiency and performance. How it does that? Putting simply, recyclerView just uses the views that have been inflated for a row again for new data when needed instead of inflating new views again. RecylerView needs to use LayoutManager that manage measuring and positioning views inside a recyclerView. You can watch the video below where I describe it in a bit more detail.


gridlayoutmanager recyclerview
A possibility of wWhat you can create with Grid Layout manager

So let's get started and create a RecyclerView with GridLayoutManager:



  1. First of all you need to add dependency to use RecyclerView, add this dependency in your app level gradle file:
    compile 'com.android.support:recyclerview-v7:25.3.1'

  2. After you've added the dependency, you can use recyclerView. Create a new layout, I named it main_activity.xml and add the following code in it:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rvMain"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>


  3. Now that we have the recyclerView ready, let's create a view that will be used by the recyclerView, i.e the view that will be visible to the user as a grid in the GridView of the recyclerView. Create a new XML file and call it recycler_item or anything you want, here's the code:
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="16dp"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/ivLogo"
            android:layout_width="80dp"
            android:layout_height="80dp" />

        <TextView
            android:layout_margin="4dp"
            android:id="@+id/tvCompany"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>


  4. Now that we have our recyclerView and the grid of the recyclerView ready, we can start referencing it in java, but before all that we first need the data that we want to display in the GridView of our RecyclerView. You can download the project from the link below and find the data in strings.xml and drawable folder. After we have our data ready, create a new Java Class, MainActivity.java and write the following code in it: Note: You will get an error for now
    RecyclerView rvMain;

        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            rvMain = (RecyclerView) findViewById(R.id.rvMain);
            Bitmap[] logos = new Bitmap[12];
            logos[0] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_apple);
            logos[1] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_fb);
            logos[2] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_google);
            logos[3] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_insta);
            logos[4] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_linkedin);
            logos[5] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_microsoft);
            logos[6] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_myspace);
            logos[7] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_skype);
            logos[8] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_snapchat);
            logos[9] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_twitter);
            logos[10] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_viber);
            logos[11] = BitmapFactory.decodeResource(getResources(), R.drawable.logo_whatsapp);
            MyAdapter adapter = new MyAdapter(getResources().getStringArray(R.array.company_list), logos);
            rvMain.setLayoutManager(new GridLayoutManager(ActivityMain.this, 2));
            rvMain.setAdapter(adapter);
        }


  5. The error you are getting in 2 of the last 3 lines is because you are using a custom adapter class but you have not created it yet. The adapter uses a view holder (I explain this in detail in the video) So let's first create a viewHolder class first, create a new class called MyViewHolder and write the following code:
    public class MyViewHolder extends RecyclerView.ViewHolder{

            public ImageView logo;
            public TextView name;

            public MyViewHolder(View itemView) {
                super(itemView);
                logo = (ImageView)itemView.findViewById(R.id.ivLogo);
                name = (TextView)itemView.findViewById(R.id.tvCompany);
            }
         }


  6. Now we have everything ready, all we need to do is create an Adapter class for our recyclerView. Create a new class called MyAdapter and write the following code in it:
    public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {

            String[] companyList;
            Bitmap[] logoList;

            public MyAdapter(String[] companyList, Bitmap[] logoList) {
                this.companyList = companyList;
                this.logoList = logoList;
            }


            @Override
            public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_item, parent, false);
                MyViewHolder viewHolder = new MyViewHolder(v);
                return viewHolder;
            }

            @Override
            public void onBindViewHolder(MyViewHolder holder, final int position) {
                holder.logo.setImageBitmap(logoList[position]);
                holder.logo.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(ActivityMain.this, "This is: " + companyList[position], Toast.LENGTH_SHORT).show();
                    }
                });
                holder.name.setText(companyList[position]);
            }

            @Override
            public int getItemCount() {
                return companyList.length;
            }
       }

Now we have our RecylerView Ready. You can now run the project and see the results, you will see a gridView like list in the recyclerView. again I recommend going through this video for learning some essential things about recyclerView. That's it for now, if you have any more questions regarding RecyclerView or GridLayoutManager feel free to drop them in the comments section below. Happy Coding! :)

SOURCE CODE DOWNLOAD LINK - RecylerView with GridLayout Manager

Monday

Set custom font in all the activities for entire application Android Tutorial

Vishal Shrestha
Everyone love a little text styling once in a while; there are various ways you can change the typeface/font of textView in your Android app, however the most simplest one is changing the typeface programmatically by applying a font to a specific textView. Although this method is simple, it requires applying the font to each textView in which you require that font. So, if you want the same font in all the Activities, you will have to provide the reference to the typeface and then apply the font manually to all the TextView, and as I am lazy, I try not to write repeated code. So in this tutorial, we will learn how to apply custom font to the TextViews in all the activities! Not only that, we will also learn how to change to font of a textView directly using XML, no java. :D
Spoiler : We will do it using our own custom textView class.
In case you are want to apply custom font to only 1 textView, you can do this easily : 

Typeface my_custom_font = Typeface.createFromAsset(getAssets(), "fonts/font_name.ttf");
myTextView.setTypeface(my_custom_font);


In the code above, we refer to font_name.ttf that is inside the fonts folder in assets folder, and then we apply it to myTextView. So now the text in myTextView will have font_name.ttf font applied.

In case you prefer Videos : Set custom font in all the activities Tutorial.
Source Code : At the Bottom of the post.

Okay now let's move on to applying custom font throughout the activities.
First create a new project, give it any name. I call it theFreakyText :P .

New-custom-font-android-project
New custom font project

The next step is to choose the Minimum SDK version. It just specifies the lowest Android version that you app supports. I just chose 21 for now. You can choose lower or higher depending on your requirements.

Minimum-SDK-for-custom-font-project
Minimum SDK for custom font project

Once you've chosen the Minimum SDK version, you will see an Activity selection screen like below. You can either choose add no activity, then you need to create your own activity. I chose Empty Activity, so choose empty activity for this tutorial.

Activity-for-custom-font-project
Empty Activity for our TypeFace project

The default name is MainActivity, you don't need to make any change. If you wish to you can.

Custom Text Main Activity


After you've chosen the name and clicked on finish, you have created an empty Activity and you will see a screen similar to this. This is the MainActivity, extend AppCompatActivity for Support to lower versions if you want.

Custom-Text-App-Compat-Activity


Now create a new class. This class will contain the code related to our custom font textView

Custom-class-extending-textView


I've named the class NastyFontTextView :D. You might want to use a different name :P
 
Custom-class-extending-textView-for-custom-typface


Since we are creating a custom TextView class, we need to have all the properties of textView. So extend the regular TextView.

Custom-Class-extending-textView-for-custom typface


Since we want to set custom font using XML, we need to create an attribute using which we will define the typeface for a particular textView. So create a new attrs.xml inside you values folder. We will later use this attribute to define the font for the textView.

Creating-new-attribue-containing-font-property


Write the code shown in the screenshot below. This is doing nothing but just adding an attribute to the class MyTextView. We can use this attribute in XML to define custom font.

MyTextView-stylabe-for-custom-font-property


Now go back to our NastyFontTextView and use the default constructor. You can do it by pressing ALT+Enter.

Implementing-default-constructor-of-TextView

You will see a list of default constructor. Use the one with attributeSet.
attributeSet-constructor-for-extending-textView-class


Once you have selected the default constructor with attribute set, you will see that the following lines of code are added.

Default-constructor-in-custom-class-extending-textView


Now we need to get the font that the we have defined using the font property in XML and then we need to apply that font. We will use chooseFont and applyFont methods for that. Write the code seen below.
Note - You will see an Error in FontCache usage right now, as it's not a predefined class. We will create it in the next step.

Select-Typeface-and-apply-typeface-methods


Loading the font whenever you require them again and again in as inefficient process. So if you've loaded a specific font already one, we will cache it so that is can be used quickly the next time. Create custom class for fontCaching call it FontCache.

Creating-font-cache-class-for-easy-loading-of-custom-font


Font cache is a simple class. It just loads the fonts from fonts folder inside the assets and stores it in a hashMap. Here is the  complete code for FontCache Class.

FontCache-getTypeface-method


Finally, we are done on the Java part. You will notice that the FontCache error is gone!

Complete-class-for-apply-custom-font-in-all-activities


Now it's the simple part. We just need to use the custom class we created, NastyFontTextView in our layout. Open activity_main and add a NastyFontTextView. It works as plain old textView till now. Add app:font to it and let the magic begin! You define your own font in this attribute.
Note : Your font must exist in the fonts folder inside assets folder. 

Creating-layout-for-custom-font


You will see an error in app:font property, add xmlns:app name space to root layout and it will be gone. Press alt + enter and it will be added automatically. In the app:font property you can write any font name that you have copied in the fonts folder and it will be applied to that textView. Yesss!

adding-custom-font-class-to-layout


We will add a few more textView so that we can demonstrate all the TextViews with different Fonts. You don't need to do that but we will just because we can! :D
Change the root layout to linear layout as we won't have to define alignment for all the TextViews.

Changing-root-layout-for-custom-font


Add a new more NastyTextViews with fonts of your choice just as in the image below!

adding-class-extending-textview-for-custom-font


We have already done everything! we just need the TypeFace in the fonts folder. You can copy any typeface just Google and download if you haven't already decided on a sexy font yet! To create assets folder do this : right click on res->new->folder->Assets folder. Now go to assets folder and create fonts folder inside it and copy your fonts in it.

adding-custom-fonts-in-assets-folder


Here's the fonts that I've added inside my fonts folder.So we've learned how to create a custom class extending TextView that can be easily used in the XML and we can change font now with just one line of code! Bravo, go party unless you have any doubts, if you have drop them in the comments and I will try to answer it asap. Cheers!

custom-fonts-in-assets-folder-to-be-applied-in-all-activities

Source Code : Download Custom Font Tutorial

Wednesday

How to create a Location Tracker App in Android complete tutorial

Vishal Shrestha
Creating a basic but functional Location Tracker app in Android is not much work, you can do it within an hour! Just follow the following tutorial. Here we will create an Android App that will access GPS or Network to figure out your current location and keep updating the Marker on the map to give the effect of "Tracking". We will be using Google Maps Android API, Android Studio and an Android Phone to test.

If you are into videos : You can watch this YouTube Video : Create an Android Location Tracker app in 30 Minutes.

Note - Find Source code of this location tracker app at the end of this article

Let's begin to create our very own Location Tracker App! Create a new project and Select the Google Maps Activity as shown in the figure below and just click next on the corresponding options and click on finish. Doing this gives us a template that already has a layout with maps fragment and an associated activity with the marker placed somewhere over Australia! We can run this app now by just adding our API_KEY.

Creating_location_tracker_app_android
Creating new MapsActivity Project


You will see a screen like this, at the second last line, notice YOUR_KEY_HERE. You need to get the API key for using google maps API for Android. You will need Google Maps to display your location on the map.

Google maps android API key
API_KEY


To get the API Key, go to this link - Google Maps Android API, and a webpage like the one below will open up. Now just click on the Maps link(The first option form the bottom image row). Update - Now you can click on GET A KEY button on top right, next to pricing and plans button.If you do this, skip the next step.

getting google maps android api key
Official Google Maps website



Now if you can see a page like this, click on the GET A KEY button right next to View Pricing and Plans button on the top right corner of the page.

Getting google maps android api key
Getting google maps API Key


Now you will be show a dialog box like the one shown below, here you need to give the project name for which you will be using Google Maps.

Google maps app android project name
Google Maps App Project Name


After you enter a valid project name, you will be shown a new dialog box with the you API KEY, Bravo. Now you can finally start coding you own Location Tracker app for Android. Copy the API_KEY shown to you in the dialog box, you will need it in the next step.

Google Maps Android API Key
Google Maps Android API Key


Now we are back in Android Studio, let's begin where we left off. Paste the API KEY that you copied from the dialog box in the previous step in the highlighted part shown in the screenshot below.
At this point we already have a functional app that puts the Marker over some place in Australia. The marker is static and you can change it to be placed over any place by defining the coordinates in the MapsActivity. You can run and test this app now, just add the following permissions in the Manifest :
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <uses-permission android:name="android.permission.INTERNET"/>

Android Studio Google Maps API Key
Android Studio Google Maps API Key



Now open your activity_maps.xml from the layouts folder inside res folder. It should look like the image shown below.

Google Maps Android Studio MapsActivity
MapsActivity


Now finally we can start some actual coding! Read, keep or remove the pre defined comments, I choose to remove it. Now create a new GoogleMap variable mMap and implement LocationListener. You need the LocationListener to be notified whenever your location changes. The implementation will show some error for now, it's because we haven't implemented the required methods yet.

LocatioinListener for getting location changes
Location Listener


To remove that error, implement all the required methods. Click ALT + Enter and you will be shown list of all the methods that can be implemented. Select all of them and click Enter. You will see the following methods and the error will have been resolved. Although there are a bunch of methods, we will only be using onLocationChanged which is called whenever new location data is received by the device. Here we handle what to do with the new data, put the marker over that point or do whatever you want with it.

Implementing LocationListener Methods
Implementing location listener methods


Now, create your own method called requestLocation. This method will be responsible for setting the criteria of the location requests that you will make. Criteria defines the accuracy level required and the power level required. According to your criteria the Android system automatically chooses GPS or Network for getting the your location so that you can focus on what you want rather that choosing the tool that you will be using.

Requesting location update from LocationManager
LocationManager and Criteria


Now you need to call the requestLocation method so the the device can try to figure out your location. But first you need to do some preparations, if you want your app to run on devices running Marshmallow or higher, you need to take care of Run Time permissions. To learn more about run time permissions, read this post - Marshmallow Runtime Permissions. You also need to add a new global Marker and MarkerOptions variable as you want to update the position of the same marker not create a new marker every time your position is changing. Initially we've set the marker position to 0,0. You'll see a lot of error for now as all the methods we've call are not yet defined. They are defined at the end of this tutorial. Write the code shown below in the screen shot.

Requesting location access permissions
Location Service Permissions


Since you have now called the requestLocation methods which requests your current location from the LocationManager, you can get you location data any second, so you need to handle your location data in the onLocationChanged method. Add the code shown below in onLocationChanged and add the marker to that place in the onMapReady.

Using onLocationChanged Method and using marker
Adding Marker on Map
Here's the code for the isLocationEnabled and isPermissionGranted method. isLocationEnabled checks if the location information can be given to apps i.e if apps are allowed to get the location information or not. isPermissionGranted method checks specifically for your app if your app is allowed to access location services or not. If not allowed it requests the permissions to the user.

Checking if location service is enabled
Checking if location service is enabled


Finally here's the code of showAlert. It shows a dialog box if the location services in your device is turned off, i.e if apps are not allowed to access you current location data. If the user choose to give the permissions then he/she is directly taken to the location setting options.

Showing alert for location service request
Showing Dialog Box

Finally our app is done! it wasn't that complex, was it? We have our own Location Tracker app which updates the marker in the map according to our position. The marker changes the position abruptly but the app tracks the location just fine. We can work on the smoothness of the change of marker's location some other time. Happy coding, if you have any problems, don't hesitate to comment below.

Source Code : Download Project Files

Android app crashes without any error or exception in logcat

Vishal Shrestha
The only thing worst than getting an error is getting an error and not knowing what error it is and where it is. This is not a common problem but every Android developer is susceptible to it. Your app might just crash without any error or without the common "Unfortunately the app has closed" message. In some cases the app is redirected to another activity after an activity has crashed. The errors are there, they are being output but they are not being displayed to you.
To fix this no error issue, you can try one of the following methods :

Android app crashes without any error or exception in logcat | Fixed:

1. Remove filters - This is the most common and simple mistake that developers make that hides the error logs from them. The logcat might have filters set that are not allowing the error logs to be shown, you can set it to only from your application or remove all the filters. I had once wasted a whole lot of my valuable time just because of this simple issue.

No-errors-show-in-logcat
No Filters in Logcat

2. Remove noHistory property of Activity in Manifest - This is not actually a crash. It's how the app is supposed to work if you have set the noHistory property in the Manifest to true. This property defines whether or not the activity should be removed from the activity back stack and finished when the user navigates to some other activity from it and it's no longer visible on screen.

3. Run in debug mode - You can try to run the app in debug mode. Android Studio has a debugger that enables you to debug the apps on the either the Emulator or any connected Android device. Here's how you can enable debugging mode in android studio, to start debugging, click Debug in the toolbar. Android Studio builds an APK, signs it with a debug key and installs it on your selected device. It is then run and the Debug window is opened for analysis.
Running app in debug mode for errors
Debug Mode
So I hope you can now finally see the details about your error in logcat and your app now crashes with error, developers have strange wishes sometimes :-P . Do let me know how it goes in the comment section below! Cheers!

Saturday

Why do Android phones need more RAM than iPhones?

Vishal Shrestha





Let's first understand the concept of RAM, technically speaking RAM (Random Access Memory) is a volatile storage used to hold data. It can be thought as a big filing cabinet that keeps things on ready to go state for the CPU to use. It's almost infinitely very fast, re-writable, and used differently by different operating systems.

Check here - Why octa core is note better than quad core?
More RAM in Android Phones

In mobile phones, when the user is not actively using an app, the system moves it to the background state. For many apps, the background state is just a brief stop on the way to the app being suspended. Suspending apps is a way of improving battery life it also allows the system to devote important system resources to the new foreground app that has drawn the user’s attention.
Strictly Speaking, Apps don't use more RAM in Android than in iPhones. Same apps tend to use almost same amount of RAM in both the devices. The differences come mainly when the app goes to the background, i.e When the app is minimized or when you press the home button. That's where the difference in RAM Management kicks in.


Here the RAM in most popular Android phones and iPhones :
iPhone and Android RAM Size

Most apps can move to the extended state easily enough but there are also legitimate reasons for apps to continue running in the background. An audio app might need to continue playing music over the lock screen. Other apps might want to download content in the background so that it can minimize the delay in presenting that content to the user. When  found necessary to keep a app running in the background, iOS helps to do so efficiently and without draining system resources or the user’s battery.

The techniques offered by iOS fall into three categories:
  1. Apps that start a short task in the foreground can ask for time to finish that task when the app moves to the background.
  2. Apps that initiate downloads in the foreground can hand off management of those downloads to the system, thereby allowing the app to be suspended or terminated while the download continues.
  3. Apps that need to run in the background to support specific types of tasks can declare their support for one or more background execution modes.
So here are the main reasons why Android Phones have more RAM than iPhones :
Note - Having more RAM has it's merits, we will discuss than in the end of this Article.

1. What Apple does is always try to avoid doing any background work unless doing so improves the overall user experience.  Apple does this efficiently and android follows another path. An app might move to the background because the user launched a different app or because the user locked the device and is not using it right now. In both situations, the user is signaling that your app does not need to be doing any meaningful work right now. Continuing to run in such conditions will only drain the device’s battery and might lead the user to force quit your app altogether.

2. Android has Garbage Collection, iOS doesn't. So what is garbage collection? It’s a process that recycles memory once an Android app is done using the memory. This works pretty well on devices that have a lot of free RAM, but if a lot of apps are running in the background, things get dicey and hence the more RAM.

3. One of the main reason why Android is laggy is because of the way it treats UI rendering. On iOS UI rendering is done in a separate thread with real-time priority, on Android this happens in the main thread with normal priority. This of course means that other apps can take over your processor resources and hurt basic UI interactions, translating into a noticeable lag. You can check it out in real time with iPhone and Android's default browsers, if you tap and hold into the Safari window while it’s loading a webpage, the loading process stops, as UI rendering has the highest priority and takes over. The result is that the webpage will not load until you lift your finger off, but the UI will remain buttery smooth all the time. Android has a radically different approach - it will try to maintain a reasonable response rate for the UI and load the webpage, but often the frame rates would drop causing a visible lag.



Android vs iPhone

So practically we can conclude that iOS doesn’t require less memory than Android or that Android needs more memory that iOS, it simply means that iOS has a better mechanism for handling the background apps and better scheme for re-purposing memory. In general it seems that Android apps that have moved to the background just sit there in their entirety and occupy almost the same amount of RAM they did when they were running in the foreground. On iOS quite the opposite is true, background apps occupy much less memory but the OS saves just enough of the app so that when the app is switched into the foreground again it is instantly available.
But less RAM in iPhones do have it's drawback, where it's most prominent is in the split view multitasking support. When we are running two apps side by side then neither of the app can reduce it's memory requirements. Since apps in Android and iOS use roughly the same amount of RAM then the 2GB on the iPad Air 2 or the iPad mini 4 is really not enough.
So OEMs typically just add an extra 1 or 2GB of memory, to counter the way Android handles background apps. That is a perfectly viable solution, however I would definitely love to see Android (i.e. Linux) handle background apps more efficiently and differently than it does today.
Please let me know what are your thought and which one of the memory management schemes you prefer!
Find Out why Octa Core is not Better than Quad Core.

Wednesday

Xiaomi Redmi Note 4 vs Redmi note 3. Redmi Note 3 is Better than Redmi note 4!

Vishal Shrestha
The Redmi note 4 has been released by Xiaomi, and it's time for some fierce Redmi note 3 vs Redmi note 4 comparison. I have looked at the specification for both the Redmi phones, looked at camera performance and daily performance and here is my opinion, I don't want the new Xiaomi Redmi Note 4, It's not worth the upgrade. I was patiently waiting for the Redmi Note 4 but it disappointed me. Here why I came to this conclusion, the most prominent factors that decide whether I'll buy the phone or not are - Camera, Performance and Looks, and all in all, the Redmi Note 3 is just not better if not worse than the note 3 in all these areas.


Redmi note 3 vs Redmi note 4

Here my summary of the Xiaomi Redmi Note 4 vs Xiaomi Redmi note 3.

Performance - Redmi Note 4 comes with a Mediatek MT6797 Helio X20, while Note 3 (Pro) is powered by a Snapdragon 650. On the paper, Note 4 has more CPU cores so it should be faster. But in real life performance, the processor on the  note 3 is better performing and gives better results in bench-marking tests too. You can read here why more cores doesn't mean better performance.

Both the devices have two variant 2GB Ram 16GB Internal Storage Versions and 3 GB RAM with 32 GB of Storage in the Redmi Note 3 Pro and 3 GB and 64 GB of storage in the Redmi note 4.
Even though the performance of Redmi note 4 is a littler better the the MediaTek version of Redmi note 3. It's not significant enough for an Upgrade, and the Redmi note 4 doesn't match the performance of Redmi note 3 Pro, even though you will rarely notice it in every day tasks.

Camera -  Putting bluntly Redmi note 3 has 16 MP and Redmi note 4 has 13 MP so Redmi Note 3 is better, but that's not the case. However the Redmi note 4 doesn't particularly stand out either. Both the cameras perform similary, but I won't deny that the Redmi note 4 has slightly better performance in some cases and in night mode, but the difference is nothing note worthy. Note 4 provided slightly better highlights and exposure. If you want to buy a phone solely based on camera, I give just a little bit edge to the note 4, but nothing substantial. 
Check out here - how to improve the camera of Redmi note 3.

Redmi note 4 camera performance


Looks -  I don't want to say much about the look, just decide from the image below. How ever I'll just say it's difficult to differentiate between the two phones looking from the front.

Redmi note 3 vs Redmi note 4 Design


All the other features of the two phones are almost exactly the same with 4100MmAh battery in the Redmi note 4 and 4050 mAh battery in the Redmi note 3. Redmi note 4 comes with Android 6.0 and Redmi note 3 has also been given Android 6.0 upgrade. So If you own a Redmi note 3 pro, I don't see a reason for you to buy the new Xiaomi Redmi note 4. Do let me know what you choose to do!

Tuesday

Is octa core better than quad core or hexa core?

Vishal Shrestha





We have seen the exponential growth of Android Smartphone market like no other, and the general marketing strategy has been focusing on the terms like more cores, more RAM and faster performance. But does more cores mean more speed? Is octa core better than quad core? Here's the break down.

Quad-core-vs-Octa-Core
Quad core vs Octa Core

Is octa core better than quad core?

Broadly speaking, core are the basic computing unit in either phones or computers and are required for all the processes taking place. So it implies that if there are more cores than there can be more task done. Simple as that. But how does Apple with just two cores in the iPhone 6 manage to have a better performance than most of the Android phones with quad core and even octa core? Even the iPhone 7 has "Only" two cores compared to Android phones with Hexa core, Octa core and even Deca core. As a user main factor we need to focus on is performance and not the technical details like cores or frequency or RAM.


From the above statements we can conclude that it's not the core count that matter, or else Apple iPhones would not be near any the performance of any Android phones much less outperform them.
so what defines the performance of a device is not core count?
Simply speaking it's not the core count that matters, but how much work can a single core do. A simple and rather stupid but easy to understand analogy here, can two bodybuilders lift more or two skinny guys? It's more or less the same thing. For example, here's the benchmark result of iPhone 6 with Samsung note 4 and HTC desire 820.

iPhone-6-dual-core-vs-quad-core-vs-octa-core
Dual core vs Quad Core vs Octa core


Digging deeper we can find that the performance depends more on other factors than just core count and speed (frequency) of a processor chip. Some overlooked but more important aspect are memory bandwidth and ability to execute threads in a more efficient way. This governs the IPC of a chip. Simply stated IPC is "the average number of instructions executed for each clock cycle". Another stupid but simple analogy is, if you need to transfer the water from one water tank to another water tank using buckets, how much water can you carry at once and how much water a pro body builder can carry at once. Here, the amount of water you can carry at once is analogous to the average number of instructions executed per clock cycle.
The reason why the performance of the dual core processor in the iPhone 6 is better than most quad core and octa core Android phones of that time is because the processor chip in was the best mobile chip in the world at that time. Now it's the same with the processor in the iPhone 7. While the prime chip maker for Android "Snapdragon" has rolled out snapdragon 835, it's flagship for Android phones with 8 cores, 4 running at 2.4 GHZ and the other 4 running at 3 GHZ, iPhone is just sticking to better performing 4 cores.
So what the idea behind Android chip maker increasing core count? In my opinion, one factor is that they focused more on increasing the core count in the beginning even though it didn't matter much because it sounds sexier. More cores is wrongly associated with better performance. And the other factor is battery consumption. Android chip makers still are creating chips that are power hungry. So if the power of a core is increased, it would adversely affect the battery life. Hence the low powered single core and multiple instances of them. A new architecture call the big.LITTLE architecture was released in 2011 where four low-power Cortex-A7 cores are coupled with four high-performance Cortex-A15 cores. ARM has improved this setup every year since, and now are providing more capable chips on both the halves of the octa-core divide. Apple on the other hand has focused on both the power and energy efficiency of their chips and have found a "perfect" intersection of performance and efficiency.
So it's clear why more cores doesn't always mean better performance. It's the core technology inside the chips that matter more in performance and efficiency than the core count. If you have any opinion or questions please feel free to drop them in the comments section below.

Coprights @ 2017 | The Code City by Vishal Shrestha Vishal Shrestha