Sign in

First time this crash, I faced when i upgraded Kotlin version to 1.4.20.
It takes much time to fix. I investigated in code to fix and below are the finding(may be there can be other solution but below worked for me)

stack track for VerifyError error is like:
Fatal Exception: java.lang.VerifyError: Verifier rejected class e.b.b.b.b.e.k: e.b.b.b.b.e.k.K() failed to…


When we start Android app development then in most of applications, key point is to make http api calls to send/get data to/from server. As Android framework already provides core classes for http calls, Using those classes, we can write own code to communicate to server. But it can be error prone.

So for fast development, Developers check if any popular library exist which can do all work. Many popular library exist for http api calls for Android.

There is no doubt, In today development for Android apps, Retrofit is very popular library. Retrofit is a type-safe REST client for…


In most of applications, There is need to upload photos/videos. It is easy to open camera and gallery via intent but developers face issues when they start to test this functionality on different Android OS versions. For example:
1. Need to declare storage permissions and handle them based on OS versions
2. Below marshmallow, Only declare permissions in manifest and system auto grant these permissions
3. From marshmallow, We need to handle runtime permissions which are declared in manifest
4. From android 10 and above, There is limitation with external storage(Scope storage)

So keep in mind, I am writing here every case which works on every OS version. I’ll break this explanation in three parts:
1. Capture photo via intent
2. Capture video via intent
3. Pick photo/video via intent
4. Upload media to server using Retrofit


In my previous articles, I explained capture photo, capture video and pick media and show bitmap and save it in scope storage.
Now it’s time to upload captured or picked media to server. I am assuming you have done your Retrofit setup. If not then check here to setup Retrofit.
To upload media, Retrofit uses multipart:
1. Declare api function:

@Multipart
@POST(URL_UPLOAD_MEDIA)
suspend fun uploadMediaApi(@Part fileAsMultipartBody: MultipartBody.Part): Response<YourServerResponsePojo>

2. Upload media file using above function:

fun uploadImage(file: File, mimeType: String) {
viewModelScope.launch {
withContext(Dispatchers.IO){
val part = MultipartBody.Part.createFormData(
"keyNameServerExpect", file.name, RequestBody.create(
MediaType.parse(mimeType),
file
)
)
//use retrofit instance to call api
val response = retrofitBuilder.getApiInterface().uploadMediaApi(part)
}
}
}
}

Previously we discussed about capture photo and capture video. Now we’ll discuss about pick photo/video from gallery:
1. Declare read storage permission in manifest:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="26"/>

2. launch video capture intent. Handle runtime permission. I check this only for ≥ 23 and ≤ 26. We can check this for all OS ≥ 23 but this is depend on your requirements. To get thumbnail, Above > 26, There is a standard function to get bitmap from uri, no requirement of absolute path.

val PICK_MEDIA= 100
private fun openGallery() {
if (Build.VERSION.SDK_INT in 23..26 && ActivityCompat.checkSelfPermission(this…

As i discussed capture photo via intent in my previous article. Same steps, We can follow for video capture. But here i’ll not pass own path to capture video. We’ll use default created path in media folder by camera app. Lets start:
1. Declare read storage permission in manifest:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="26"/>

2. launch video capture intent. Handle runtime permission. I check runtime permission only for ≥ 23 and ≤ 26. We can check this for all OS ≥ 23 but this is depend on your requirements. …


Request the camera feature:
If an essential function of your application is taking pictures, then restrict its visibility on Google Play to devices that have a camera:

<manifest … >
<uses-feature android:name=”android.hardware.camera”
android:required=”true” />

</manifest>

If your app does not require(not mandatory to have) a camera in order to function then set android:required to false.

Request Camera to take photo:
1.
Declare Request code:
val REQUEST_IMAGE_CAPTURE = 100

2. Launch Camera intent:

private fun dispatchTakePictureIntent() {
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) …

Android OS 11 has been rollout and it has many lots of new features and some major behavior changes. I’ll discuss one major change which is related to location behavior change.

Android 11 changed permission dialog behavior. When you will request for location it’ll ask with three options: 1.while using the app 2. only this time 3. deny

Android 11 location permission dialog

Only this time means: When you’ll kill your app and relaunch then it’ll again ask for permission.This maintain permission state for single app launch session.

One thing to remember, In Android 11, If user press deny two times after that permission dialog…


Android introduced new class to support view paging. i.e. ViewPager2. It is recommended to integrate this because older class i.e ViewPager will not be further maintained.

I come to main point for what i want to discuss. In my one app, I have to implement search screen where i needed to remove and add fragment based on conditions.

For example. I had four fragments A, B,C and D. Scenario:
1. When first time user visit search screen. Only show fragment A
2. When user type and search then show result in fragment B, C and D. Remove fragment A
3. User cancel…


When we integrate Paytm SDK. Paytm SDK requires Checksum in it’s request body to validate request data.

Paytm provide checksum generator helper classes for different languages.
Check below link:
https://developer.paytm.com/docs/checksum/

But all above helper classes/library are helpful for server side(Recommended way to generate checksum at server side for security purpose). There is no specially for android/ios/other mobile platform.

When we start to integrate Paytm sdk in Android or other mobile platform. You should always try to generate checksum at server side. …

DKumar

Mobile App Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store