如何在Javascript中读取从C#传递的params object []项?(How to read params object[] items passed from C# in Javascript?)
我正在Silverlight中执行一个简单的程序,以便在silverlight中添加javascript函数。
银光功能如下
void InvokeJS(params object[] items) { object result = System.Windows.Browser.HtmlPage.Window.Invoke("JSFunction", items); }
该函数的值为pase正在发生
InvokeJS((object)new object[]{ (object)"10", (object)"20"})
并且JS功能如下
function JSFunction(params) { alert(params); }
现在如何在javascript中读取params值?
I am doing a simple program in Silverlight to inkove javascript function in silverlight.
The silverlight function is as under
void InvokeJS(params object[] items) { object result = System.Windows.Browser.HtmlPage.Window.Invoke("JSFunction", items); }
Pasing value to this function is happening as under
InvokeJS((object)new object[]{ (object)"10", (object)"20"})
And the JS function is as under
function JSFunction(params) { alert(params); }
Now how to read the params value in javascript?
原文:https://stackoverflow.com/questions/10174441
最满意答案
我在我的应用程序中实现了一个文件选择器
那不是“文件选择器”。 这是一个内容选择器。
我需要一种能够在Android设备上选择任何文件的方法,以便我可以将其上传到我的后端。
嗯,这很大程度上取决于你在这句话中的字面意义。
ACTION_GET_CONTENT
一般不是问题。 但是,你得到的不一定是文件。 但是,您仍然可以上传它们,假设您用于上传的任何内容都允许您从InputStream
上传。 如果是这样,请在ContentResolver
上使用openInputStream()
,传入Uri
,以获取要使用的InputStream
。如果您真的需要它作为实际文件,您可以直接在您的应用程序中实现文件选择器UI。 有这个库 。 但是,您将无法访问所有文件 - 特别是,您无法使用此文件从Android 4.4+上的可移动存储上传文件。
I have a file picker implemented in my app like this
That is not a "file picker". It is a content picker.
I need a way to be able to pick any file on Android device so that I can upload it to my backend.
Um, well, that depends a fair bit on how literal you are in that sentence.
ACTION_GET_CONTENT
is not a problem in general. However, what you get are not necessarily files. However, you can still upload them, assuming that whatever you are using for the uploading allows you to upload from anInputStream
. If so, useopenInputStream()
on aContentResolver
, passing in theUri
, to get theInputStream
to use.If you really need it to be actual files, you can implement a file-picker UI directly in your app. There are libraries for this. However, you will not be able to access all files — in particular, you cannot use this to upload files from removable storage on Android 4.4+.
相关问答
更多-
在Spring中没有从消息属性文件中获取验证消息(Validation messages not picked up from message properties file in Spring)[2023-06-26]
Yaaaargh,我认为这从来就不应该起作用。 我认为有可能将JSR-303注释的“message”属性解释为一个键,以便从message.properties文件中获取关联的错误消息,但我知道我错了。 @Size(min = 3, max = 40, message="errors.requiredfield") 我的同事正在编写一个为我们创建此行为的图层,但默认情况下它不起作用。 好像我有一次工作,因为我正在使用它 @Size(min = 3, max = 40, message="{errors.re ... -
Android:如何在ACTION_GET_CONTENT中设置初始目录(Android: How to set initial directory in ACTION_GET_CONTENT)[2022-07-04]
我给了备份文件,我正在写一个.sbu的扩展名,我无法弄清楚如何在ACTION_GET_CONTENT意图上创建文件资源管理器,只过滤.sbu文件 这是不可能的。 当我的INTENT打开默认的文件浏览器时,设置一个默认的初始目录 对此, ACTION_GET_CONTENT协议中没有任何内容。 很大程度上,这是因为ACTION_GET_CONTENT不绑定到文件和目录。 此外,没有“默认文件浏览器”,特别是在Android 4.3及更早版本上。 您可以争辩说Storage Access Framework U ... -
Google云端硬盘和ACTION_GET_CONTENT的安全例外情况(Security Exception with Google Drive and ACTION_GET_CONTENT)[2022-01-25]
我有同样的问题。 抛出异常是因为Google驱动器清单中存在导出错误以管理获取内容意图。 使用它是不可靠的。 最后我使用了Google Drive API并详细介绍了newOpenFileActivityBuilder()方法的示例文档 I had the same problem. The exception is thrown because there is an export false in Google drive manifest to manage the get content inten ... -
从运行Android 4.3及更低版本的支持设备中的同一页面稍微向下一点: ACTION_OPEN_DOCUMENT意图仅适用于运行Android 4.4及更高版本的设备。 如果您希望应用程序支持ACTION_GET_CONTENT以适应运行Android 4.3及更低版本的设备,则应在清单中为运行Android 4.4或更高版本的设备禁用ACTION_GET_CONTENT意图过滤器。 应将文档提供者和ACTION_GET_CONTENT视为互斥。 如果您同时支持它们,您的应用程序将在系统选择器UI中出现 ...
-
当你运行bootRun ,它会在build/classes下找到/shop ,所以path会给你本地的文件系统路径,这个路径可以自然的和File 。 但是,当打包到WAR文件中时,WAR内部找到的资源的path不再是有效的文件系统路径。 它将使用WAR文件的路径和WAR内资源的路径进行编码。 为了使它工作,而不是File ,使用javaClass.getResourceAsStream("/shop/somefile.json")并从InputStream读取返回。 你的下一个问题将是,通过File你可以遍 ...
-
使用ACTION_GET_CONTENT选择文件路径的正确方法(Proper way to get file path when it's picked using ACTION_GET_CONTENT)[2023-12-22]
我在我的应用程序中实现了一个文件选择器 那不是“文件选择器”。 这是一个内容选择器。 我需要一种能够在Android设备上选择任何文件的方法,以便我可以将其上传到我的后端。 嗯,这很大程度上取决于你在这句话中的字面意义。 ACTION_GET_CONTENT一般不是问题。 但是,你得到的不一定是文件。 但是,您仍然可以上传它们,假设您用于上传的任何内容都允许您从InputStream上传。 如果是这样,请在ContentResolver上使用openInputStream() ,传入Uri ,以获取要使用的 ... -
我正在使用ACTION_GET_CONTENT,以便用户可以选择文本文件 不,您正在使用ACTION_GET_CONTENT以便用户可以选择MIME类型为text/*某些内容。 内容的来源主要取决于用户。 它可能是也可能不是文件系统上的文件,如果是,可能是也可能不是您可以直接访问自己的文件(例如,Dropbox应用程序的内部存储,Android 4.4+设备上的可移动存储上的文件) )。 路径应为/ storage / emulated / 0 / Documents / myFile 不,它不应该。 但它 ...
-
无法使用`ACTION_GET_CONTENT`的Uri创建文件(Cannot create a file using the Uri of `ACTION_GET_CONTENT`)[2022-10-18]
ACTION_GET_CONTENT用于从设备中选择pdf。 这允许用户选择一段内容。 它不必是一个文件。 在活动结果中,我得到了Uri并将其保存为String。 这不是你如何使用Uri 。 它产生路径为/document/primary:Download/Aptitude_2016_17.pdf。 那不是文件系统路径。 这是具有content方案的Uri的一部分。 您没有从ACTION_GET_CONTENT获取文件。 你得到一个指向一段内容的Uri 。 那个Uri可以指向用户和其他应用选择的任何内容 : ... -
我需要获取文件的名称。 它不是文件。 这是一个Uri ,就像https://stackoverflow.com/questions/43615264/how-to-get-the-file-name-from-an-uri-got-from-action-get-content-intent是一个URI。 how-to-get-the-file-name-from-an-uri-got-from-action-get-content-intent不是文件名。 我究竟做错了什么? 您假设ACTION_GET_ ...
-
通过Android上的文件管理器获取对文件系统的非法访问权限(Gaining illicit access to file system through file managers on Android)[2021-12-07]
我同时发现,在OI文件管理器的情况下,这已被报告和修复: http : //blog.k3170makan.com/2014/02/path-disclosure-vulnerability-in-io.html https:/ /github.com/openintents/filemanager/commit/78ffa735924292e541f3b7f20ead605f053f0df4 不幸的是,在F-Droid上发布的版本仍然很脆弱。 I found out in the mean time th ...