fixed crash when attempting to start connection for install referer

This commit is contained in:
Daniel Gultsch 2020-05-03 12:05:18 +02:00
parent 3577afea4e
commit 0ee9dbcea7
1 changed files with 15 additions and 13 deletions

View File

@ -31,7 +31,11 @@ public class InstallReferrerUtils implements InstallReferrerStateListener {
return; return;
} }
this.installReferrerClient = InstallReferrerClient.newBuilder(welcomeActivity).build(); this.installReferrerClient = InstallReferrerClient.newBuilder(welcomeActivity).build();
this.installReferrerClient.startConnection(this); try {
this.installReferrerClient.startConnection(this);
} catch (SecurityException e) {
Log.e(Config.LOGTAG, "unable to start connection to InstallReferrerClient", e);
}
} }
public static void markInstallReferrerExecuted(final Activity context) { public static void markInstallReferrerExecuted(final Activity context) {
@ -41,18 +45,16 @@ public class InstallReferrerUtils implements InstallReferrerStateListener {
@Override @Override
public void onInstallReferrerSetupFinished(int responseCode) { public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) { if (responseCode == InstallReferrerClient.InstallReferrerResponse.OK) {
case InstallReferrerClient.InstallReferrerResponse.OK: try {
try { final ReferrerDetails referrerDetails = installReferrerClient.getInstallReferrer();
final ReferrerDetails referrerDetails = installReferrerClient.getInstallReferrer(); final String referrer = referrerDetails.getInstallReferrer();
final String referrer = referrerDetails.getInstallReferrer(); welcomeActivity.onInstallReferrerDiscovered(referrer);
welcomeActivity.onInstallReferrerDiscovered(referrer); } catch (final RemoteException e) {
} catch (RemoteException e) { Log.d(Config.LOGTAG, "unable to get install referrer", e);
Log.d(Config.LOGTAG, "unable to get install referrer", e); }
} } else {
break; Log.d(Config.LOGTAG, "unable to setup install referrer client. code=" + responseCode);
default:
Log.d(Config.LOGTAG, "unable to setup install referrer client. code=" + responseCode);
} }
} }