First of all, to manage data in a private database in your Android phone/tablet, we will use SQLite as it is embedded into every Android device.
We need to import android.database.sqlite for access to those classes of SQLite to manage your database in your apps.
滴水穿石
2014年1月2日 星期四
2013年9月2日 星期一
START_STICKY, START_NOT_STICKY, START_REDELIVER_INTENT
All these are to tell android system what to do if the service is got 'killed'
As you know, there are lots of services keep running in the background and they will consume some memory. For simplicity, under 2 situation will the services being terminated:
- When our device memory goes down to a critical level it will automatically start terminating services to release memory.
- Users manually stopped the services (Oh! I find you the invisible memory killer!! Go to die!!! .\ /. )
As you know, there are lots of services keep running in the background and they will consume some memory. For simplicity, under 2 situation will the services being terminated:
- When our device memory goes down to a critical level it will automatically start terminating services to release memory.
- Users manually stopped the services (Oh! I find you the invisible memory killer!! Go to die!!! .\ /. )
2013年7月4日 星期四
BigDecimal.divide ArithmeticException
Sometimes, when we are using the divide function of BigDecimal like this:
The following exception will be thrown:
Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
This is caused as the division results into a recurring decimal which cannot be represented by BigDecimal.
To solve this, simply add rounding parameters into the function divide(divisor, scale, roundingMode):
BigDecimal d1 = new BigDecimal(1); BigDecimal d2 = new BigDecimal(3); BigDecimal result= d1.divide(d2); // 1/3 = 0.33333333....
The following exception will be thrown:
Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
This is caused as the division results into a recurring decimal which cannot be represented by BigDecimal.
To solve this, simply add rounding parameters into the function divide(divisor, scale, roundingMode):
BigDecimal d1 = new BigDecimal(1); BigDecimal d2 = new BigDecimal(3); BigDecimal result= d1.divide(d2, 2, BigDecimal.ROUND_HALF_UP); // 1/3 = 0.33
2013年7月2日 星期二
Android Service
For simplicity,
For those running in foreground, they are called 'Activity' (those applications we can see and use in our mobile)
For those running in background, they are called 'Service' (those we cannot see while running in background and keep consuming your mobile's RAM. Haha they are one of the evilest guys that make your mobile so slow)
For those running in foreground, they are called 'Activity' (those applications we can see and use in our mobile)
For those running in background, they are called 'Service' (those we cannot see while running in background and keep consuming your mobile's RAM. Haha they are one of the evilest guys that make your mobile so slow)
2013年5月28日 星期二
Notification with Big View
A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture. Expanded notifications are available starting with Android 4.1.
2013年5月21日 星期二
Spinner with item text aligned to center
In Android, text in Spinner is defaulted to align to left. To change the alignment, we need to create our own layout for the Spinner
2013年4月18日 星期四
SAP - Availability Check
The availability of components in an order can be checked automatically during order creation and/or order release
The availability of components in a plan order can be checked manually by MDVP
The availability of components in a plan order can be checked manually by MDVP
訂閱:
文章 (Atom)