Skip to main content

Posts

Showing posts from May, 2017

Implementing RecyclerView

I'm working on Android hybrid apps from last 5 years, its very tough to stay in touch with Native android UI, Now I started learning through sample applications, so thought of sharing my learning here.           RecyclerView has came with Material design in Android Lollipop, RecyclerView is advanced, flexible version of Listview, RecyclerView uses the view holder pattern  and improve the performance by reusing off screen views and rebinds them to the data which is scrolling on the screen, now lets see the difference between list view and recyclerview. Difference between RecyclerView and Listview :- 1. RecyclerView forces to use RecyclerView.ViewHolder (Inbuilt view Holder) to hold the elements, to reuse the cells while scrolling, which was optional in Listview which we used to create in adapters getView() method. 2. Animation while adding list items or removing list items are already added in the recyclerview. 3. List views were only of vertical...

Launch an Android application on Bootup

If you want to start an android application on device restarts, you need to listen for BOOT_COMPLETED broadcast in the manifest file and launch the Launcher activity in onreceive of BOOT_COMPLETED broadcast receiver. Follow below steps to launch activity on device boot up :- 1. Register for Boot completed receiver in Android Manifest file. Add below Permission to receive BOOT_COMPLETED broadcast, <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> Register for Boot completed broadcast receiver , <receiver android:name="AppAutostartReceiver" android:enabled="true" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> 2. Add custom Broadcast receiver in the application, public class AppAutostartReceiver extends BroadcastReceiver { @Override public void onReceive(Context cont...