Say we need to open the default messaging app in android and want to allow user to send a particular text message to a provided number. Below is the code to achieve this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("smsto:"+ number)); //provide a valid number
intent.putExtra("sms_body", smsBody); //provide an sms body
The above code will open the default messaging app with the provided sms body. But there might be a situation where OS might not find proper activity to handle this implicit intent. So it might throw ActivityNotFoundException. Therefore it’s better to handle such exception by using try/catch block.
While coding we may face some integer overflow cases for large inputs. Today I am going to discuss about two such scenarios which I have faced during problem solving.
Say you are given a sorted integer array and you are asked to find a particular element in that array. Since the array is sorted we can apply binary search algorithm to find the target element in O(logN) time; here N is the size of the input array.
The basic idea of binary search is each time we divide the array in half, find the mid index and compare the target…
Blameless Postmortem Culture in Software Engineering
Imagine the following scenario:
One day one of your colleagues told you that there is a bug in production and the entire system suddenly stopped running. So he asked for your help to identify the issue. Now you and your teammates are trying to find out what caused the entire system to fall apart. After some digging it’s finally revealed that there are some lines of code which are actually buggy and they found out you wrote those lines of code.
So who is to blame in this situation? Is it you? It might…