Skip to content

Commit

Permalink
fix: check if the referrer is not null before casting it to a string (#…
Browse files Browse the repository at this point in the history
…425)

This is to prevent NullPointerException
  • Loading branch information
1abhishekpandey authored May 20, 2024
1 parent a739a78 commit 3b58967
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
import android.os.Build;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.rudderstack.android.sdk.core.ReportManager;
import com.rudderstack.android.sdk.core.RudderLogger;
import com.rudderstack.android.sdk.core.RudderMessage;
import com.rudderstack.android.sdk.core.gson.RudderGson;

import java.io.File;
Expand All @@ -26,7 +24,6 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -200,7 +197,8 @@ public static boolean fileExists(Context context, String filename) {
public static String getReferrer(Activity activity) {
// If devices running on SDK versions greater than equal to 22
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
return activity.getReferrer().toString();
Uri referrer = activity.getReferrer();
return referrer != null ? referrer.toString() : null;
}
// If devices running on SDK versions greater than equal to 19
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Expand Down

0 comments on commit 3b58967

Please sign in to comment.