Skip to main content

Posts

SSL pinning in Android - A brief discussion

HTTP protocol Communication between the client and a server typically non-encrypted or plain text while we use HTTP protocol.  Pitfall Any middle hacker can interrupt the connection between the client and server and manipulate the data as it involves no encryption. How to overcome this ? As the domain owner one can purchase a digital certificate from CA(Certificate Authority) who are considered as trusted.  A certificate will contain the Owner's name, public key , Issuer's(CA's) name,Issuer's(CA's) signature, domain details, expiry date etc . After the SSL/Leaf certificate is associated with a domain,the communication between client and server will be encrypted. Now the HTTP will become HTTPs. Note : Associating the SSL certificate means it enable the encryption between client and server but does not mean ,the domain owner will never misuse your personal information. How does SSL work ? Pitfall There is a problem here. Let's assume that there is a hacker comes i...
Recent posts

Dependency Injection using Hilt

 Few Essentials to know 1. @HiltAndroidApp 2. Constructor Injection & Field Injection - @Inject 3.  @ AndroidEntryPoint 4. @Module, @InstallIn 5. @Provides 6. @Binds 7. @ActivityScoped/@Singleton/@ViewModelScoped etc 8. ActivityComponent, FragmentComponent, SingletonComponent etc. Please complete the codelab practice  https://developer.android.com/codelabs/android-hilt#0 Full Reference https://developer.android.com/training/dependency-injection/hilt-android

Manual Dependency Injection- Realtime Explanation

Assume that we have a Login Feature in Android application and it will have the classes based on the Android's recommended architecture such as MVVM. --> The  LoginActivity has the dependency of LoginViewModel . --> The LoginViewModel has the dependency of UserRepository --> The UserRepository has the dependency of UserLocalDataSource and UserRemoteDataSource UserRepository.kt class UserRepository ( private val localDataSource : LocalDataSource, private val remoteDataSource : RemoteDataSource ) { // Manipulating data from local and/or remote data sources. } Data Sources class LocalDataSource {} class RemoteDataSource ( private val retrofitLoginService : RetrofitLoginService) { } LoginViewModel.kt class LoginViewModel ( private val userRepository : UserRepository) { //Invocation of methods in UserRepository class } LoginActivity.kt class LoginActivity : AppCompatActivity { private var lateinit loginViewModel: LoginViewModel; public fun onCreate (bun...

Dependency Injection - Overview

Advantages of DI Reusability of code Ease of refactoring Ease of testing For an Example, Car class and Engine class. A Car should have an object of Engine. How to achieve it ? 1. By creating an Engine object in Car class   <-- This provides the tight coupling of Engine object in the Car class. This approach makes testing difficult. 2. By creating a global class from where we can access the Engine object in the way we access getSystemService(), getContext() etc. <-- This is called service locator pattern. As it is global place to access all objects, the testing will still become difficult.  3. By passing the object of Engine object when constructing the Car class <-- This is called Dependency Injection An Example of Car tightly coupled with Engine class Car { private val engine = Engine() fun start () { engine .start() } } class ClassA { fun main (Array arr){ var car : Car () car.start() } } Drawback  Let's conside...

Android - Activity Life cycle

The android activity provides 7 call backs which will be invoked based on the states of the activity For better undersatnding,The Activity A and Activity B with the all the call backs overridden. ActivityA :  public class ActivityA extends Activity {     @Override    protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         Log.e("A-OnCreate", "Object Creation");     }     public void next(View v) {         Intent i = new Intent(this, Main2Activity.class);         startActivity(i);     }     @Override    protected void onStart() {         super.onStart();         Log.e("A-onStart", "View is visible but will not be able to interact");     } ...

The Reality of Developer’s Life very funny... :)

When you upload something to production environment: When you find a problem solution without searching in Google: When you close your IDE without saving the code: When you try to fix a bug at 3AM: When your regular expression returns what you expect it: When my boss reported me that the module I have been working will never be used: When I show to my boss that I have fixed a bug: When I upload a code without tests and it works as expected: When marketing folks show to developers what they have sold: The first time you apply a CSS to a web page: When the sysadmin gives you root access: When you run your script the first time after several hours working on it: When you go on weekend and everyone else are at office trying to fix all issues: When your boss finds someone to fix a critical bug: When you receive an extra paid if project ends before deadline: When something that had worked on Friday and on Monday did not work: ...

Android -Expandable ListView

 I've discussed the coding snippets of Expandable List view .The Expandable List view is user-friendly and can make the Indication for what it has been group with the help of group item . we now can discuss about that user friendly Expandable list view code-wise , activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context=".MainActivity" >     <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerHorizontal="true"         android:layout_centerVertical="true"         android:text="@string/hello_world" /> </RelativeLayout> The Group Item de...