double d1 = 123456.78; double d2 = 567890; Locale fmtLocale = Locale.getDefault(Category.FORMAT); NumberFormat formatter = NumberFormat.getInstance(fmtLocale); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); System.out.println(formatter.format(d1)); System.out.println(formatter.format(d2)); System.out.println(fmtLocale.toLanguageTag());
Android
Screen goes white before splash in android
<activity android:name=”first Activity Name” android:theme=”@android:style/Theme.Translucent.NoTitleBar”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity> In Android studio 2.0 or above version it is happening because of instant run. by removing it from settings>Bulid, Execution, Deployment> Instant run and disable all the check boxes over there …
How save the state of RecyclerView row item?
If you are using RecyclerView you need to maintain states of each row, means if you are checking using a condition(i.e. if) at any stage of RecyclerView item(in recyclerview adapter class) then you need to handle else as well. Here is the sample RecyclerViewAdapter : …
Select IN() query in firebase database android
Firebase doesn’t have an equivalent for a SQL SELECT * FROM table WHERE id IN (1,2,3). The performance increase over retrieving the items separately would be marginal at best, because Firebase already pipelines the requests over a single connection. Another way is denormalizing the database or making …
Remove mirror(flip,invert) effect after capturing photos from front camera
If you are using API level >= 14, you can easily use a TextureView to mirror the preview image back to the original. for SurfaceView you can apply Matrix to a captured Bitmap in onPictureTaken method. private Camera.PictureCallback mPicture = new Camera.PictureCallback() { @Override …
Android Nougat Support : FileProvider Concept
In Android N, Opening a file from the SD card is different. When targeting Android N, file:// URIs are not allowed anymore. We should use content:// URIs instead. FileProvider class is used to give access to the particular file or folder to make them accessible …
Frame By Frame Animation On Marker Android.
Frame By Frame Animation: Frame by frame animation is an animation in which sequence of images replaces on image view. This animation supports on image view in android. Problem: How to do same animation on google map location marker ? Impediment: addMarker() method of GoogleMap …
Get typing status of EditText in Android
You can determine whether the user is typing or not you have to create one CustomEditText class which extends to EditText. This type of functionality is widely used in Chat application. Here is a snippet of CustomEditText public class CustomTypingEditText extends CustomEditTextNormal implements TextWatcher { …
Firebase customise notification when app is in background or killed
Firebase will not call your onMessageReceived when your app is in background or killed, and you can’t customise your notification. System generated notification will show. to make firebase library to call your onMessageReived in every cases a) Foreground b) Background c) Killed you must not …
Defining item click listener for RecyclerView in Android
Android RecyclerView doesn’t come with the Item Click Listener that you have with ListView. You will have to implement the item clicke listener yourself. Below link have an example of how to implement the view holder item clicker listener in RecyclerView. In a nutshell, The Activity …