Scenario
I have a WebView application in an Android application that contains an embedded Soundcloud (from Embedly). This insert has two buttons: "Play Soundcloud" and "Listen in the browser."
The Play on Soundcloud button contains a URL in the format intent://tracks:257659076#Intent;scheme=soundcloud;package=com.soundcloud.android;end
The code
My WebView uses a custom WebViewClient (because I need to intercept some URLs for some other things).
protected class WebViewClient extends android.webkit.WebViewClient {
public WebViewClient() { }
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
if (resolveInfoList != null && resolveInfoList.size() > 0) {
Intent viewUrlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(viewUrlIntent);
}
else {
}
return true;
}
}
Problem
" " . " Soundcloud" shouldOverrideUrlLoading WebViewClient ( ). , URL- Soundcloud.
WebViewClient WebView ( ), "Play on Soundcloud" , , Soundcloud.
()
, , , URL-, , URL-, , Soundcloud ( SO). URL- "soundcloud://tracks:[TRACK_ID]" Soundcloud.
?
, ", URL", - , , , (?!) WebViewClient, WebView, ? .