- Home /
Custom Chrome tab
There is an application. Assembled without problems. Need to add a button, when you click, a ChromeTab opens and follows the link. When adding a ChromeTab.java the build is aborted. Error 1: Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details > Configure project :launcher WARNING: The option setting 'android.enableR8=false' is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. You will no longer be able to disable R8 > Task :unityLibrary:preBuild UP-TO-DATE > Task :launcher:preBuild UP-TO-DATE > Task :launcher:preReleaseBuild UP-TO-DATE > Task :unityLibrary:preReleaseBuild UP-TO-DATE > Task :unityLibrary:compileReleaseAidl NO-SOURCE > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
Error 2: D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:8: error: package androidx.browser.customtabs does not exist import androidx.browser.customtabs.CustomTabsIntent; ^ D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:9: error: package androidx.browser.customtabs.CustomTabsIntent does not exist import androidx.browser.customtabs.CustomTabsIntent.Builder; ^ D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:14: error: package CustomTabsIntent does not exist CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); ^ D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:14: error: package CustomTabsIntent does not exist CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); ^ D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:16: error: cannot find symbol CustomTabsIntent customTabsIntent = builder.build(); ^ symbol: class CustomTabsIntent location: class ChromeTab Note: D:\Docs\GameDev\Test\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 5 errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'. > Compilation failed; see the compiler error output for details.
ChromeTab.java
package com.unity3d;
import android.net.Uri;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.app.Activity;
import android.graphics.Color;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsIntent.Builder;
public class ChromeTab
{
public static void Show(String url, Activity activity, int r, int g, int b)
{
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Color.rgb(r, g, b));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try
{
customTabsIntent.launchUrl(activity, Uri.parse(url));
}
catch (ActivityNotFoundException ex)
{
try
{
customTabsIntent.intent.setPackage("com.android.browser");
customTabsIntent.launchUrl(activity, Uri.parse(url));
}
catch (Exception e)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
activity.startActivity(browserIntent);
}
}
}
},There is an application. Assembled without problems. Need to add a button, when you click, a ChromeTab opens and follows the link. When adding a ChromeTab.java the build is aborted.
Error 1:
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
Error 2:
D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:8: error: package androidx.browser.customtabs does not exist
import androidx.browser.customtabs.CustomTabsIntent;
^
D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:9: error: package androidx.browser.customtabs.CustomTabsIntent does not exist
import androidx.browser.customtabs.CustomTabsIntent.Builder;
^
D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:14: error: package CustomTabsIntent does not exist
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
^
D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:14: error: package CustomTabsIntent does not exist
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
^
D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\ChromeTab.java:16: error: cannot find symbol
CustomTabsIntent customTabsIntent = builder.build();
^
symbol: class CustomTabsIntent
location: class ChromeTab
Note: D:\Docs\GameDev\CatchColorChromeTab\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
ChromeTab.java :
package com.unity3d;
import android.net.Uri;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.app.Activity;
import android.graphics.Color;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsIntent.Builder;
public class ChromeTab
{
public static void Show(String url, Activity activity, int r, int g, int b)
{
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Color.rgb(r, g, b));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try
{
customTabsIntent.launchUrl(activity, Uri.parse(url));
}
catch (ActivityNotFoundException ex)
{
try
{
customTabsIntent.intent.setPackage("com.android.browser");
customTabsIntent.launchUrl(activity, Uri.parse(url));
}
catch (Exception e)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
activity.startActivity(browserIntent);
}
}
}
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Google USB driver version 11 backward compatible with XP? 0 Answers
An OS design issue: File types associated with their appropriate programs 1 Answer
Empty Application.persisentDataPath on Android device causing UnauthorizedAccessException 1 Answer