-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
40 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
.../modules/module_common/src/main/java/github/tornaco/android/thanos/util/BrowserUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package github.tornaco.android.thanos.util; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import androidx.browser.customtabs.CustomTabsIntent; | ||
|
||
public class BrowserUtils { | ||
|
||
@SuppressLint("QueryPermissionsNeeded") | ||
public static void launch(Context context, String url) { | ||
try { | ||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); | ||
CustomTabsIntent customTabsIntent = builder.build(); | ||
customTabsIntent.launchUrl(context, Uri.parse(url)); | ||
} catch (Throwable e) { | ||
final Intent intent = new Intent(); | ||
intent.setAction(Intent.ACTION_VIEW); | ||
intent.setData(Uri.parse(url)); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
if (intent.resolveActivity(context.getPackageManager()) != null) { | ||
context.startActivity(Intent.createChooser(intent, "")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters