-
-
Save iniyanmurugavel/cb4470d9108f061265c2c18882e899b7 to your computer and use it in GitHub Desktop.
Important Questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Lazy Loading Design Pattern | |
| Lazy loading is a concept where we delay the loading of object until the point where we need it. | |
| Lazy loading is just a fancy name given to the process of initializing a class when it’s actually needed. | |
| In simple words, Lazy loading is a software design pattern where the initialization of an object occurs only | |
| when it is actually needed and not before to preserve simplicity of usage and improve performance. | |
| Lazy loading is essential when the cost of object creation is very high and the use of the object is very rare. | |
| So this is the scenario where it’s worth implementing lazy loading. | |
| The fundamental idea of lazy loading is to load object/data when needed. | |
| this@MainActivity - it is a reference to current MainActivity instance. | |
| MainActivity@this - it is definition of a name of the label, i.e. MainActivity | |
| 2. Slow network handling | |
| blog -> https://android.jlelse.eu/designing-android-apps-to-handle-slow-network-speed-dedc04119aac | |
| Its best to design your app to handle the lack of network connection, provide a friendly feedback to the user and never show user a raw error message | |
| In Android, there are ways to determine your connection speed | |
| Using NetworkInfo class, ConnectivityManager and TelephonyManager to determine your network type. | |
| Another test is to download some file from the internet & calculate how long it took vs number of bytes in the file. | |
| Use Facebook’s Network Connection Class library to figure out the quality of the current user’s internet connection on the fly. | |
| Using an external library which does the job well is not a bad approach but it is essential to always know how to write your own solution as oppose to using a library. | |
| NetworkInfo info = Connectivity.getNetworkInfo(context); | |
| if(info.getType() == ConnectivityManager.TYPE_WIFI){ | |
| } else if(info.getType() == ConnectivityManager.TYPE_MOBILE){ | |
| // check NetworkInfo subtype | |
| } | |
| NetworkInfo info = Connectivity.getNetworkInfo(context); | |
| if(info.getType() == ConnectivityManager.TYPE_WIFI){ | |
| // do something | |
| } else if(info.getType() == ConnectivityManager.TYPE_MOBILE){ | |
| // check NetworkInfo subtype | |
| if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_GPRS){ | |
| // Bandwidth between 100 kbps and below | |
| } else if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_EDGE){ | |
| // Bandwidth between 50-100 kbps | |
| } else if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_0){ | |
| // Bandwidth between 400-1000 kbps | |
| } else if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_A){ | |
| // Bandwidth between 600-1400 kbps | |
| } | |
| // Other list of various subtypes you can check for and their bandwidth limits | |
| // TelephonyManager.NETWORK_TYPE_1xRTT ~ 50-100 kbps | |
| // TelephonyManager.NETWORK_TYPE_CDMA ~ 14-64 kbps | |
| // TelephonyManager.NETWORK_TYPE_HSDPA ~ 2-14 Mbps | |
| // TelephonyManager.NETWORK_TYPE_HSPA ~ 700-1700 kbps | |
| // TelephonyManager.NETWORK_TYPE_HSUPA ~ 1-23 Mbps | |
| // TelephonyManager.NETWORK_TYPE_UMTS ~ 400-7000 kbps | |
| // TelephonyManager.NETWORK_TYPE_UNKNOWN ~ Unknown | |
| } | |
| ###OOM Error###### | |
| Runtime.getRuntime().freeMemory() to find memory space if available when ever it exceed catch block will not able handle oom error | |
| What is GPU Rendering? | |
| The GPU is the Graphics Processing Unit. At its core, it's very similar to the CPU, | |
| but instead of doing calculations | |
| and performing tasks related to the operating system and hardware, | |
| the GPU handles the graphical information. In other words, it puts stuff on the screen for your eyes to see | |
| ########## Hardware Acceleration ############# | |
| By rendering all of an app’s animations and UI with the GPU, the system takes a hit to memory usage. | |
| Loading up the OpenGL drivers for each process takes memory usage of roughly 2MB, and boosts it to 8MB. | |
| On devices with limited RAM, this can be a real issue. When more RAM is eaten up, the system will necessarily have | |
| to close more background tasks to save memory. | |
| Some developers might not want to use the GPU for drawing as a result. | |
| By enabling Hardware Acceleration, the performance of your application's UI may improve considerably. | |
| To enable Hardware Acceleration on an application, | |
| simply add the android:hardwareAcceleratedtag to the manifest file. | |
| After adding that tag to the application element, simply recompile and test your app. | |
| It is very important to fully test your app after you add this line. Although it's unlikely that | |
| Hardware Acceleration will negatively affect your app, it is certainly possible. | |
| It is a good idea to make sure all of the views and animations still work as you expect it to. | |
| If you find that certain screens seem to have problems with Hardware Acceleration, | |
| you can disable it on a per Activity basis if needed as well. To do so, simply add the tag | |
| (set to false) to the activity tag within the manifest. This allows you to enable Hardware Acceleration | |
| for the entire application while removing it for certain parts. And this also works in the reverse. | |
| You can enable only specific Activities while leaving it off for the majority of the application. | |
| Hardware acceleration is enabled by default if your Target API level is >=14, but can also be explicitly enabled. | |
| If your application uses only standard views and Drawable s, turning it on globally should not cause any | |
| adverse drawing effects. | |
| Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline supports hardware acceleration, | |
| meaning that all drawing operations that are performed on a View's canvas use the GPU. | |
| Because of the increased resources required to enable hardware acceleration, | |
| your app will consume more RAM. | |
| You can control hardware acceleration at the following levels: | |
| Application | |
| Activity | |
| Window | |
| View | |
| <application android:hardwareAccelerated="true"> | |
| <activity ... /> | |
| <activity android:hardwareAccelerated="false" /> | |
| </application> | |
| OpenGL ES | |
| Android includes support for high performance 2D and 3D graphics with the Open Graphics Library (OpenGL®), | |
| specifically, the OpenGL ES API. OpenGL is a cross-platform graphics API that specifies a standard software | |
| interface for 3D graphics processing hardware. | |
| Android supports OpenGL both through its framework API and the Native Development Kit (NDK). current version 3.1 above 5.0 | |
| onSurfaceCreated method() | |
| OpenGL ES is a flavor of the OpenGL specification intended for embedded devices. | |
| OnSurfaceView () Method using inside and android uses opengl es using ndk | |
| ### Handler Update the Ui Simple #### | |
| final int intervalTime = 10000; // 10 sec | |
| Handler handler = new Handler(); | |
| handler.postDelayed(new Runnable() { | |
| @Override | |
| public void run() { | |
| //Display Data here | |
| } | |
| }, intervalTime); | |
| new CountDownTimer(11000,10000) { | |
| @Override | |
| public void onTick(long millisUntilFinished) { | |
| // Display Data by Every Ten Second | |
| } | |
| @Override | |
| public void onFinish() { | |
| ActionStartsHere(); | |
| } | |
| }.start(); | |
| ################ POM ######################## | |
| A Project Object Model or POM is the fundamental unit of work in Maven. | |
| It is an XML file that contains information about the project and configuration details | |
| used by Maven to build the project. | |
| It contains default values for most projects. | |
| ######## WEBView############### | |
| Multi-threading and Thread Blocking | |
| If you call methods on WebView from any thread other than your app's UI thread, | |
| it can cause unexpected results. For example, if your app uses multiple threads, | |
| you can use the runOnUiThread() method to ensure your code executes on the UI thread: | |
| runOnUiThread { | |
| // Code for WebView goes here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment