Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Callbacks from Chrome Tabs in android like web View provides shouldOverrideUrlLoading, onLoadResource, onPageFinished

I am trying to replace the web view with Chrome Custom tabs in my project. For replacing webview, I need a callback in the Chrome tab like the android web view provides. So are there any callbacks available or not and if available, then what are they? Please help me. Thanks in advance.

like image 306
Faisal Khan Avatar asked May 01 '17 12:05

Faisal Khan


People also ask

How do I see my tabs on Google Mobile?

Change tab view in Chrome Android To change the tab view in Chrome Android, you simply need to click on the number icon which can be found right next to the browsers address bar. This will take you to the new grid view in Chrome.

How many tabs can you open in Chrome Android?

With Google Chrome 106, the shell of Tab Groups will be overlooked while counting the accurate number of open tabs. Notably, 99 is the maximum number of tabs which Chrome can show and with no Tab Groups shield the number is easily attainable, especially for those who use the Android app regularly.


1 Answers

you can only provide the following callbacks in chrome custom tabs:

/**
* Sent when the tab has started loading a page.
*/
public static final int NAVIGATION_STARTED = 1;

/**
* Sent when the tab has finished loading a page.
*/
public static final int NAVIGATION_FINISHED = 2;

/**
* Sent when the tab couldn't finish loading due to a failure.
*/
public static final int NAVIGATION_FAILED = 3;

/**
* Sent when loading was aborted by a user action before it finishes like clicking on a link
* or refreshing the page.
*/
public static final int NAVIGATION_ABORTED = 4;

/**
* Sent when the tab becomes visible.
*/
public static final int TAB_SHOWN = 5;

/**
* Sent when the tab becomes hidden.
*/
public static final int TAB_HIDDEN = 6;

To attach a callback, bind to the custom tabs service as normal, and just pass your callback while calling newSession().

more info: https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#newSession(android.support.customtabs.CustomTabsCallback)

implementation guide: https://developer.chrome.com/multidevice/android/customtabs#implementationguide

like image 59
Vardaan Sharma Avatar answered Nov 01 '22 01:11

Vardaan Sharma