How can I pass a url to an android app using href? - android

I'm trying to pass a link to mpv-android. I want to do it via href using intents
Something like this :
<a href="mpv//https://video/url.mp4">
But its not working. Can someone help me with this.
mpv-android github:https://github.com/mpv-android/mpv-android/blob/master/app/src/main/AndroidManifest.xml

Try using an intent
Check these out.
1
2
3
4

Found the solution here. Since the manifest filters depending on MIME type or URLs with a few select extensions (mkv, mp4, webm, m3u, ...) you need to trick Android into opening mpv anyway by specifying a valid-looking type.

Related

Deep link path gets cut to 2 segments

Implemented deep linking in my app, but can't quite understand how Uri.getPath() method works... It looks like it cuts the path to 2 segments but why?
Why is that? I can't see any other method that would return me the whole path.
Here is the explanation: (from wikipedia)
hierarchical part
┌───────────────────┴─────────────────────┐
authority path
┌───────────────┴───────────────┐┌───┴────┐
abc://username:password#example.com:123/path/data?key=value#fragid1
└┬┘ └───────┬───────┘ └────┬────┘ └┬┘ └───┬───┘ └──┬──┘
scheme user information host port query fragment
according to this
http://developer.android.com/reference/android/net/Uri.html#getPath()
it is decode your path. Read full doc for better understanding about Uri

Work with the link with special character (e.g. traditional chinese , empty space) in android

I am working with special character in URL for android
However, I encounter two problem
1) empty space
If I have a query inside url
e.g. test.php?test=aaa bbbb cccc
Then the query will not include bbbb and cccc, I learnt that I should replace the " " to %20, however, instead of using replace(" ","%20"), how can I do it in more standard way?
2) traditional chinese in url
I have an image url like this:
http://oshc.zizsoft.com/wp-content/uploads/2014/04/1-職安健資訊產品目錄2013-220x300.png
If I directly pass to android, it fail. but if I copy the link to my desktop browser , it change to like this, then I paste it on android, it works
"http://oshc.zizsoft.com/wp-content/uploads/2014/04/1-%E8%81%B7%E5%AE%89%E5%81%A5%E8%B3%87%E8%A8%8A%E7%94%A2%E5%93%81%E7%9B%AE%E9%8C%842013-220x300.png";
What should I do to encode to this?
Thanks for helping
Update:
it change to
http%3A%2F%2Foshc.zizsoft.com%2Fwp-content%2Fuploads%2F2013%2F12%2FSQ1-351x300.jpg
How can I fix that? Thanks
1) Try trimming the url, it wil remove the spaces from url. I guess its bit more staanddard way to solve this issue.
2) This problem is eactly due to the encoding issues. Our Android default encoding is cp1252...and those strings will not be encoded in the same way so when it used in the code its automatically changes to some other symbols. So try changing the encoding of the project and string to the same like UTF-8 or something. You can change project encoding by
Properties> Resources> Encoding
Hope my suggesions will help you a bit.
Try this links also
1. Trimming
2. Encoding
If you want to programmatically encode and decode URLs then use URLEncoder and URLDecoder class available in Java as well as Android.
// To encode URL
URLEncoder.encode(url, charset);
// to decode url
URLDecoder.decode(url, charset);

Using googles panorama API

I want to use google's API for displaying panoramas. Apparently I need for input a jpg with the panorama, in which I embed the metadata in XMP format. How can this be done? is it my job as a developer or the one's who creates the panorama? can this be done with a tool? ie photoshop?
Ok this is how I did it, I used photoshop which has an option to pass metadata from a custom template so I created an XMP file using the metadata mentioned in google documentation page. Hope it helps anyone who finds this post!
<?xpacket begin='' id=''?><x:xmpmeta xmlns:x='adobe:ns:meta/'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:CaptureSoftware>Photo Sphere</GPano:CaptureSoftware>
<GPano:StitchingSoftware>Photo Sphere</GPano:StitchingSoftware>
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
<GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>
<GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>
<GPano:InitialViewPitchDegrees>0.0</GPano:InitialViewPitchDegrees>
<GPano:InitialViewRollDegrees>0.0</GPano:InitialViewRollDegrees>
<GPano:InitialHorizontalFOVDegrees>75.0</GPano:InitialHorizontalFOVDegrees>
<GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
<GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
<GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
<GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
<GPano:FullPanoWidthPixels>4000</GPano:FullPanoWidthPixels>
<GPano:FullPanoHeightPixels>2000</GPano:FullPanoHeightPixels>
<GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>
<GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>
<GPano:SourcePhotosCount>50</GPano:SourcePhotosCount>
<GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>
</rdf:Description>
</rdf:RDF>

All properties of intent.putExtra to crop image in android

I'm creating an app where the user will use the camera or choose some photos from the gallery.
I'm trying to put some rules when the user chooses the photo from the album but I don't know all the properties and I tried to search some site or tutorial but I didn't found anything.
Someone knows where I can find this or learn the properties.
Properties like this
intent.putExtra("crop","true");
intent.putExtra("aspectX",10);
intent.putExtra("aspectY",10);
intent.putExtra("outputX",256);
intent.putExtra("outputY",256);
intent.putExtra("return-data",true);
I need to disable the resize function from the crop screen and I want to learn more about working with an android camera.
Thanks and regards to everyone.
"return-data"
"cropped-rect"
"aspectX"
"aspectY"
"spotlightX"
"spotlightY"
"outputX"
"outputY"
"scale"
"data"
"scaleUIfNeeded"
"outputFormat"
"set-as-wallpaper"
"noFaceDetection"
I refer you to Mr. Murphy's post here: http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html

Why is WebView unable to open some local URLs (Android)?

I have a WebView that I'm using to open some files stored in the assets/ directory of my project. It works fine for most of the files, but there's one in particular (and I'm sure others I haven't found) that it just will not open.
The file I'm having problems with is named:
"assets/ContentRoot/Photos/XXX Software Logo - jpg - 75%.JPG"
When I pass it to WebView, and it shows the error page, it shows it as:
"file:///android_asset/ContentRoot/Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%.JPG"
I then tried running URLEncoder.encode() on it and got the error page with the URL presented as:
"file:///android_asset/ContentRoot/Photos/XXX+Software+Logo+-+jpg+-+75%.JPG"
Neither of these URLs were able to open the file (and they both look okay to me). Anyone have any ideas?
UPDATE: If I encode the % by hand (using %25, as commonsware.com suggested) then it loads the image, but it tries to parse it as text, not as an image, so I just get a lot of (basically) garbage.
Also, referring to the image in an HTML document with a relative URL isn't working (probably because it's not being parsed as an image?):
<img src="../Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%.JPG" />
<img src="../Photos/XXX%20Software%20Logo%20-%20jpg%20-%2075%25.JPG" />
Okay, after spending way too long on this, I've figured out what's going on. Basically, if images stored in the assets/ directory contain a space (e.g., " ") in their file name, they won't render as images.
myWebView.loadUrl("file:///android_asset/testimage.jpg");
works fine. However,
myWebView.loadUrl("file:///android_asset/test+image.jpg");
just throws a not found error and
myWebView.loadUrl("file:///android_asset/test image.jpg");
// and
myWebView.loadUrl("file:///android_asset/test%20image.jpg");
show it improperly displayed (as text... see screenshot in question).
This unexpected behaviour is present on (at least) 1.5, 1.6, and 2.0 and I filed a bug report.
Try getting rid of the % in the filename. Or, escape it as %25.
I would guess that WebView only understands text related content types so it faithfully treating your JPG as base64 encoding, decodes and displays resulted gobble-goop as text. I don't really know if it's possible to set content type for WebView but as workaround you can try to throw img tag inside html tag and load resultet page. Also you probably can only use WebView#loadDataWithBaseUrl

Categories

Resources