bitbox-wallet-app icon indicating copy to clipboard operation
bitbox-wallet-app copied to clipboard

Android: links not opening

Open BrianCraig opened this issue 4 years ago • 2 comments

Links don't open on android:

https://user-images.githubusercontent.com/4956754/147910429-81f6511c-ebc1-417f-8294-ce2241eb864c.mp4

with a slight modification they work, still all the intent filtering on the app would stop working

diff --git a/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/Util.java b/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/Util.java
index 885bdf47..200d765a 100644
--- a/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/Util.java
+++ b/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/Util.java
@@ -1,5 +1,7 @@
 package ch.shiftcrypto.bitboxapp;
 
+import static androidx.core.content.ContextCompat.startActivity;
+
 import android.app.Application;
 import android.content.Intent;
 import android.net.Uri;
@@ -10,9 +12,7 @@ public class Util {
         // https://developer.android.com/guide/components/intents-common.html#java
         Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        if (intent.resolveActivity(application.getPackageManager()) != null) {
-            application.startActivity(intent);
-        }
+        startActivity(application.getApplicationContext(), intent, null);
     }
 
     public static void log(String msg) {

https://user-images.githubusercontent.com/4956754/147911231-f4c9c831-85c3-45fe-95d0-977fe924eca6.mp4

BrianCraig avatar Jan 03 '22 08:01 BrianCraig

with a slight modification they work, still all the intent filtering on the app would stop working

what does that mean exactly?

how did you figure out the code change? the previous code used to work - any idea why it stopped working? The linked page still has code exactly like it is in our app: https://developer.android.com/guide/components/intents-common.html#java

benma avatar Jan 03 '22 10:01 benma

ping @BrianCraig

benma avatar Jan 26 '22 13:01 benma

Update on this: it seems that since Android 11 package visibility has been reduced.

https://developer.android.com/training/package-visibility https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9

I opened a PR to fix this, see https://github.com/digitalbitbox/bitbox-wallet-app/pull/1793

Beerosagos avatar Oct 10 '22 13:10 Beerosagos

PR merged, closing

Beerosagos avatar Oct 11 '22 06:10 Beerosagos