August 13, 2021

Android multi-language support

In this article we are going to build multi-language supported app. We are going to support Gujarati language strings in our android application. How String localisation works: By default android considers English as primary language and loads the string from res->values->strings.xml. When you want to support another  language, you need to create a values folder by appending an Hyphen and the ISO language code. You can check […]

August 13, 2021

Use font-awesome for Icon in android

Use font-awesome for Icon in android Here is steps to how to use font-awesome fonts in Android : Download font-awesome from here Create assets folder in app/src/main directory. Now create fonts folder in assets folder You can use it in two ways… either create Custom class which extends TextView or Manually get instance of TextView in Activity and then set font. To choose font visit this site and check all icons. Here describes both ways..   […]

August 13, 2021

Lock own app functionality for android

The simple demo to create lock screen activity for your android app: Create one activity which ask for password or pin. It is may be like Create MyApplication class which  extends Application class. Set application name in Manifest.xmlandroid:name=”.MyApplication” ………> Now you need two static variable in MyApplication file. public static boolean locked; private static long time = 0; Now define two methods to track app […]

August 13, 2021

custom switch library for android. Easy to use and with all customization

Custom switch library for android. Easy to use and with all customization. Follow these steps to use this switch: 1. Download customSwitchLibrary module from here2. Add it in your project.3. Add dependency to your project : compile project(path: ‘:customswitchlibrary’) 4. Now it is ready to use with your project.5. To add view in xml, write tag with this: lj.customswitchlibrary.ViewSwitch 6. Now it is ready. Customize in […]

August 13, 2021

Implement search functionality with EditText and RecyclerView in android

Search functionality with recyclerview in android.  Here is simple demo to make your recyclerview searchable. By following this demo you can implement search functionality to your RecyclerView in android. Here I got country list and display in Recyclerview.Follow these steps to implement search functionality with RecyclerView : Create new project with Android studio. Create xml file for MainActivity with RecyclerView and EditText to search. Create list […]

August 13, 2021

Android: Dynamic column number in GridView and Gridlayout manager

If you want to change grid item dynamically then follow these steps. This will help you to achieve your goal. For GridView just do : final GridView gridView = (GridView) rootView.findViewById(R.id.gridView); int gridViewEntrySize = getResources().getDimensionPixelSize(R.dimen.grip_view_entry_size); int gridViewSpacing = getResources().getDimensionPixelSize(R.dimen.grip_view_spacing); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int numColumns = (display.getWidth() – gridViewSpacing) / (gridViewEntrySize + gridViewSpacing); gridView.setNumColumns(numColumns); For Recyclerview use this layout manager […]

August 13, 2021

How to solve SSLHandshake exception in android with OkHttp

Here is how to handle SSL handshake error in android with Okhttp. This tutorial includes links from android developer site and the details information given at https://developer.android.com/training/articles/security-ssl.html If you got this kind of error while network operation then this demo will help you to save your time : javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:374) at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209) at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478) at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433) at […]

August 13, 2021

How to append or write data into text file in android?

Here is demo for creating text file and append text to that file in JAVA. For this in Android you have to ask for WRITE_EXTERNAL_STORAGE permission. you can check this : if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_STORAGE_INT); return; } } Please handle this request in onRequestPermissionsResult.   Finally actual code to write text file in java is :  try{ […]

August 13, 2021

Best practices for Memory management so reduce OutOfMemory crash

Android provides such a huge range of devices with different different configuration. For developer it is necessary to keep in mind that if device with 8GB ram available, then also device with 512MB ram available. To create a good app developer should take care of this. Here you can find general tips for memory optimization which will help you reduce your memory usage : Avoid […]