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());
Technology
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 …
Continue run application in background mode without suspended by OS.
We can solve this by using background task and runloop mechanism. Below piece of code can save your day for problem like run app in background continue. Initialise var UIBackgroundTaskIdentifier var bgTask:UIBackgroundTaskIdentifier! bgTask = application.beginBackgroundTaskWithName(“MyTask”, expirationHandler: {() -> Void …
Download & Store files in documents directory iOS phone-gap application
Hello, Here is the code for download and store files in document directory ios phone-gap app. var fileTransfer = new FileTransfer(); fileTransfer.download( uri, filePath, function(entry) { alert(“download complete: ” + entry.toURL()); } }, function(error) { alert(“download error source ” + error.source); alert(“download error target ” …
DFP Banner & Interstitial Ads in iOS
//DFPBannerView //ViewController.h 1. @import GoogleMobileAds 2. @property (nonatomic, weak) IBOutlet DFPBannerView *bannerView; 3. Design UIView which custom class is DFPBannerView //ViewController.m – (void)viewDidLoad { [super viewDidLoad]; NSLog(@”Google Mobile Ads SDK version: %@”, [DFPRequest sdkVersion]); self.bannerView.adUnitID = @”/6499/example/banner”; //To get your own adUnitID refer reference links …
Auto verification OTP
It is not possible to access your mobile SMS in iOS for some security reasons but if you want that feature you can implement below things: -You can get your verification code according to mobile number from server side. -generate URL scheme of your app …
RealtimeChat with Firebase
KEY FEATURES Firebase backend (full realtime actions) Realm local database (full offline availability) AES-256 encryption FEATURES Live chat between multiple devices Group chat functionality Private chat functionality Single or Multiple recipients Push notification support No backend programming is needed Native and easy to customize user …
Play All Video without freeze and gap between two videos
1. Implement SHBQueuePlayer third party class you can download from github: https://github.com/jiutianhuanpei/SHBQueuePlayer 2. Implement AVPlayerViewController class 3. The below function is used for set urls for play video. – (void)setUrls:(NSMutableArray *)urls index:(NSInteger)index { [_playedUrls removeAllObjects]; [_nextUrls removeAllObjects]; if (urls.count == 0 || urls == nil) …