The Icon of MediaItem can not display in Android Wear via MediaBrowserServiceCompat - android

I use setIconUri set a online Image URL at MediaDescriptionCompat Builder like this
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(item.getlistId());
builder.setTitle(item.getlistName());
builder.setIconUri(Uri.parse(item.getlistIconM()));
Bundle bundle = new Bundle();
bundle.putInt(BUNDLE_KEY_MEDIA, R.string.title_theme);
then the Image of MediaItem display perfect at Android Auto, but not at Android Wear, why ?
and what should I do fixed this issue ?

Android Wear only loads remote URLs from https - if you are using http URLs, you should switch to https.

Related

Android webview loading amazon s3 url's fails

I am having a pdf url from amazon s3 bucket and I am trying to open that with my webview but it doesn't works and it shows only blank screen.
Eg Url - https://XYZwest-1.amazonaws.com/XYZ.pdf?X-Amz-Expires=86400&x-amz-security-token={TOKEN HERE}&X-Amz-Algorithm={Algorithn}Amz-Credential={AWS CREDS}&X-Amz-Date=20220815T154223Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature={Signature}
This is how I have my webview setup -
val settings = binding.webView.settings
// Enable java script in web view
settings.javaScriptEnabled = true
binding.webView.setLayerType(View.LAYER_TYPE_HARDWARE, null)
binding.webView.settings.domStorageEnabled = true
binding.webView.loadUrl(webUrl)
```.

Mixed Content Error when playing ads In Jwplayer sdk

I have an android project where I integrate the JWplayer sdk, the player is playing video well
The problem is when the player arrive to play the ads it show me this exeption :
"Mixed Content: The page at 'https://intercept.jw//data/user/0/user/files/jwplayer/jw_core/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://myXmlAdsFile'. This request has been blocked;
I tried those solution without a result:
turn my link to https:
did not work, it shows me an insecure link exeption
allow mixed content:
I dont have a web view in the player so can not use this method
this is my code to initialize my jwplayer:
List<AdBreak> adSchedule = new ArrayList<>();
AdBreak adBreak = new AdBreak.Builder()
.tag(My Xml Link)
.offset(time when the ads show up)
.build();
adSchedule.add(adBreak);
Advertising advertising = new Advertising(AdSource.VAST, adSchedule);
PlaylistItem playlistItem = new PlaylistItem.Builder()
.file(videoUrl)
.build();
List<PlaylistItem> playlist = new ArrayList<>();
playlist.add(playlistItem);
config = new PlayerConfig.Builder()
.playlist(playlist)
.advertising(advertising)
.build();
jwPlayerView.setup(config);

Play Youtube Video in Cardboard mode

I'm developing a cardboard app. In my app I want to play a 360 youtube video, I want it to go straight to VR mode so the user doesn't have to remove their headset.
I don't mind whether this video is embedded in my app or opens the youtube app, but I need it go directly into VR mode with no non-VR interaction.
I've looked into doing the following:
streaming the video onto a surfaceTexture and using this to render stereoscoptically: not Possible
Launching the youtube app in cardboard mode: Not Possible
Using the YoutubePlayerView/Fragment/standalonePlayer : None expose functions to enable cardboard mode.
Is this possible?
I ended up using DASH with exoplayer.
I grabbed the direct url like so:
String GET_VIDEO_INFO_URL = "http://www.youtube.com/get_video_info";
Bundle params = new Bundle();
params.putString("video_id", info.getId());
UrlUtils.HttpURLRequest request = new UrlUtils.HttpURLRequest(GET_VIDEO_INFO_URL, "GET", params);
String response = request.execute();
if(response != null) {
Bundle urlParams = UrlUtils.decodeUrl(response);
String manifest_url = urlParams.getString("dashmpd", null);
info.setPath(manifest_url);
}
Then I use exoplayer to render the dash stream to a texture as explained here.

Xamarin Forms - iOS Use webView in app, and not in default browser

I'm been using the WebView in my project to show a couple of webpages in app.
On Android this works fine. but on iOS it's open the default browser insted of showing it in app, like when you use
Device.OpenUri(new Uri(e.Url))
My code look like this
webView = new WebView
{
Source = new UrlWebViewSource
{
Url = "http://www.google.com",
},
VerticalOptions = LayoutOptions.FillAndExpand
};
this.Content = webView ;
Any one here who know how to make the iOS open the page in-app ?
Using Device.OpenUri will often even according to the Xamarin documentation here, navigate outside the application.
If you want to host the content within your application, the best approach would be to embed the Webview, that it looks like your doing, and set the .Source to a url.
I don't understand why your using Device.OpenUri if you have a WebView instance already on your page.
Just set the .Source property of the WebView to point at some url.
For example:-
WebView objMyWebView = new WebView();
objMyWebView.Source = "http://www.google.com";

Custom Tabs Support Library

Recently was added this support library, but I couldn't find any example.
What the purpose of this library?
Could you post any example using this library?
CustomTabs is used to open links in a browser that supports CustomTabs. Most likely opening is done on Chrome, hence CustomTabs is part of chromium platform.
Purpose is to avoid implementing WebViews in your application and yet giving you option for styling actual chrome tabs, like toolbar color, title, various exit/enter transition, adding action buttons and menues. CustomTabs will allow your application bind to the chrome service and make chrome work as part of your application. Styling which will give you feel the opened web resource is part of your application.
Beside the styling, CustomTabs will give you full chrome web capabilities that probably couldn't be achieved with standard WebView.
Here are demos, which are straight forward.
Edit:
A snippet from my application which is "simplified" version of the Google's demo, lacking fallback mechanism, for now.
Usage of the helper is the following:
Initialize it when your activity is alive
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
mCustomTabHelper = new SimpleCustomChromeTabsHelper(this);
}
2. When the instance is alive and we have an url ready to be opened we can call:
mCustomTabHelper.prepareUrl(mProduct.getRedirectUrl());
Which will bind to the Chrome service, if not previously bind, or will just notify Chrome service that we might be opening that link in the future.
CustomTabSession can be used to open or prepare multiple url.
Open the url
mCustomTabHelper.openUrl(mProduct.getRedirectUrl());
The overloaded method of openUrl is using sort of ui options builder that is replica of the CustomTabIntent.Builder, but I have dropped the CustomTabsSession argument so the helper later will build CustomTabIntent internally.
I'm running Chrome Dev version along stable one. If I choose the stable one, I'm not able to use CustomTabsat all. As Google advices, CustomTabs will only work on Chrome 45 and beta versions of Chrome.
Demo from my application: https://youtu.be/fnIZwuJXjHI
Edit: Post
Try this:
gradle dependency:
dependencies {
...
compile 'com.android.support:customtabs:25.1.0'
}
Code :
Uri uri = Uri.parse("https://github.com/mzelzoghbi");
// create an intent builder
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
// Begin customizing
// set toolbar colors
intentBuilder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// build custom tabs intent
CustomTabsIntent customTabsIntent = intentBuilder.build();
// launch the url
customTabsIntent.launchUrl(activity, uri);
There is demo project on github, mentioned by #NikolaDespotoski, which can be partially reusable.
Solution is based on this article.
Add project shared to your project. Shared is a name of project (I don't know why Google didn't add it into customtabs library). link to shared project
Copy Activity helper from demo project to your project and put correct package. CustomTabActivityHelper
To pre-fetch url use CustomTabActivityHelper#mayLaunchUrl method (if needed) and CustomTabActivityHelper#openCustomTab to open Chrome custom tab.
For instance openning custom tab:
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, uri,
new CustomTabActivityHelper.CustomTabFallback() {
#Override
public void openUri(Activity activity, Uri uri) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
Pre-fetching of url is more complicated. You can see this demo for better understanding.

Categories

Resources