小编nLL*_*nLL的帖子

为什么indexOf不能在IE8阵列上工作?

以下功能适用于Opera,Firefox和Chrome.但是,在IE8中它失败了if ( allowed.indexOf(ext[1]) == -1).

有谁知道为什么?有没有明显的错误?

function CheckMe() {
    var allowed = new Array('docx','xls','xlsx', 'mp3', 'mp4', '3gp', 'sis', 'sisx', 'mp3', 'wav', 'mid', 'amr', 'jpg', 'gif', 'png', 'jpeg', 'txt', 'pdf', 'doc', 'rtf', 'thm', 'rar', 'zip', 'htm', 'html', 'css', 'swf', 'jar', 'nth', 'aac', 'cab', 'wgz');
    var fileinput=document.getElementById('f');
    var ext = fileinput.value.toLowerCase().split('.');
    if ( allowed.indexOf(ext[1]) == -1) 
    {
        document.getElementById('uploadsec').innerHTML = document.getElementById('uploadsec').innerHTML;
        alert('This file type is not allowed!');
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript internet-explorer indexof internet-explorer-8

291
推荐指数
5
解决办法
12万
查看次数

Android AudioRecord强制另一个流到MIC音频源

更新3:我与另一位开发人员合作,我们似乎找到了一个可以为一大笔钱做这件事的人.他们给我们发了一个测试apk,它似乎工作.我们将继续购买该来源.我希望我们不会被骗.我发现后我会更新

更新2:仍在努力.在经历了更多痛苦的日子后,我现在认为没有任何花哨的事情发生,但他们只是在原生方使用AudioFlinger(请参阅链接)来调用AudioFlinger :: setParameters

我现在正在寻找如何编写一个简单的JNI来调用AudioFioger :: setParameters with audio_io_handle_t ioHandle,const String8&keyValuePairs

我知道keyValuePairs可以是什么,但不是关于audio_io_handle_t的线索

更新:我现在相信其他应用可能正在使用QF音频与CAF.请参阅链接上的 audio_extn_utils_send_audio_calibration

链接中的 voice_get_incall_rec_snd_device 相同

我没有C/++知识.我怎样才能知道我是否可以从原生方面调用这些方法?由于其他应用程序可以,必须有一种方法.


我每天至少要工作5-6个小时,一直在努力奋斗40天.我不确定是否允许这样做,但我很乐意为正确答案捐款.

我有一个使用VOICE_CALL音频源的通话录音应用程序.尽管ASOP没有实现/授权,但大多数制造商已经实施了VOICE_CALL,使用VOICE_CALL音频源的应用在许多设备上运行良好.那是直到Android 6.

谷歌改变了Android 6的这种行为.现在打开VOICE_CALL音频源需要android.permission.CAPTURE_AUDIO_OUTPUT,它只被授予系统应用程序.

这基本上会停止通话记录,或者它应该有.好吧,它确实为我和200多个其他通话录音应用程序,除了3个已找到解决此限制的方法.

我一直在使用Android 6在许多不同的手机上尝试这些应用程序,并在他们设法记录的方式中发现了某些特征.

他们都使用Android AudioRecord类并打开MIC音频源.我也做; 但在我的应用程序中,我只从MIC而不是另一方获得音频.我发现的是告诉我他们在开始录制之前或之前发出了某种系统调用.

看一下成功记录VOICE_CALL的应用程序之一的以下日志形式,即使它使用MIC进行记录.看起来应用程序是如何管理混合/路由/流/合并VOICE_CALL音频源到MIC.

- D/audio_hw_primary: in_set_parameters: enter: kvpairs=input_source=1;routing=-2147483644
- D/PermissionCache: checking android.permission.MODIFY_AUDIO_SETTINGS for uid=10286 => granted (432 us)
- D/audio_hw_primary: in_set_parameters: enter: kvpairs=input_source=4;routing=-2147483584;format=1
- D/audio_hw_primary: select_devices: out_snd_device(0: ) in_snd_device(283: voice-dmic-ef)
- D/hardware_info: hw_info_append_hw_type : device_name = voice-dmic-ef
- D/voice: voice_get_incall_rec_snd_device: in_snd_device(283: …
Run Code Online (Sandbox Code Playgroud)

c java android android-ndk qualcomm

81
推荐指数
1
解决办法
6404
查看次数

Android AppCompat v21提供的SwitchCompat不提供SwitchCompatPerefrence

似乎AppCompat v21提供的SwitchCompat不提供SwitchCompatPerefrence.

我知道我可以使用SwitchPreference但它在视觉上并不相同.在Android 4.x上; 当我在活动界面上使用v21的SwitchCompact时,它看起来像是材质切换按钮,但是,因为没有SwitchCompactPreference,我必须在我的pereference视图中使用SwitchPreference,显然它有Android 4.0外观.

它看起来像AppCompact v21半完成.

我错过了什么吗?

android android-appcompat switchcompat switchpreference

14
推荐指数
3
解决办法
5907
查看次数

与regenerateExpiredSessionId ="false"的区别和regenerateExpiredSessionId ="true".net

我的理解来自

http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.regenerateexpiredsessionid.aspx

regenerateExpiredSessionId ="false "的含义是,如果会话ID过期,如果客户端请求具有相同ID的URL,则不会重新使用它.

和的悲风regenerateExpiredSessionId ="真"是,如果会话ID过期它将被重新使用(回收的),如果客户机请求与相同的id的网址.

但是当我读到帖子时

regenerateExpiredSessionId无法按预期工作

似乎我误解了regenerateExpiredSessionId ="true"的含义.

有人可以解释哪个是对的吗?

asp.net cookieless

11
推荐指数
2
解决办法
2万
查看次数

让我了解面向对象的编程

我是入门级.Net开发人员并使用它来开发网站.我从经典的asp开始,去年用一本简短的C#书跳上了船.随着我的发展,我学到了更多,并开始看到来自经典的asp我总是使用C#像脚本语言.例如,在我的上一个项目中,我需要在网络服务器上对视频进行编码并编写类似的代码

public class Encoder
{
    Public static bool Encode(string videopath) {

        ...snip...

        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

在搜索与我的项目相关的样本时,我看到有人这样做

public class Encoder
{
    Public static Encode(string videopath) {
        EncodedVideo encoded = new EncodedVideo();

        ...snip...

        encoded.EncodedVideoPath = outputFile;
        encoded.Success = true;

        ...snip...
    }
}

public class EncodedVideo
{
    public string EncodedVideoPath { get; set; }
    public bool Success { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

据我所知,第二个例子是面向对象的,但我没有看到使用EncodedVideo对象的意义.

难道我做错了什么?是否真的有必要在Web应用程序中使用这种代码?

c# oop object

11
推荐指数
1
解决办法
1047
查看次数

生成透明的PNG c#

我有以下功能来生成示例徽标.我想要做的是返回透明的png或gif而不是白色背景.我该怎么做?

private Bitmap CreateLogo(string subdomain)
{

    Bitmap objBmpImage = new Bitmap(1, 1);
    int intWidth = 0;
    int intHeight = 0;
    Font objFont = new Font("Arial", 13, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
    Graphics objGraphics = Graphics.FromImage(objBmpImage);
    intWidth = (int)objGraphics.MeasureString(subdomain, objFont).Width;
    intHeight = (int)objGraphics.MeasureString(subdomain, objFont).Height;
    objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
    objGraphics = Graphics.FromImage(objBmpImage);
    objGraphics.Clear(Color.White);
    objGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
    objGraphics.DrawString(subdomain, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
    objGraphics.Flush();
    return (objBmpImage);


}
Run Code Online (Sandbox Code Playgroud)

这是最终结果

context.Response.ContentType = "image/png";
            using (MemoryStream memStream = new MemoryStream()) 
            { …
Run Code Online (Sandbox Code Playgroud)

c# png transparency

8
推荐指数
2
解决办法
3万
查看次数

在C#中构建动态正则表达式模式

我正在尝试构建一个正则表达式模式,其中包含从数据库中检索的某些模式部分.

例如

string pt= "@\"\\b(" + db.GetPattern + ")\\b\"";        
Regex regex = new Regex(pt, RegexOptions.IgnoreCase | RegexOptions.Compiled);
return regex.Replace(input, "*");
Run Code Online (Sandbox Code Playgroud)

虽然我试图逃避它,但我无法让它发挥作用.如果我手动构建模式

Regex regex = new Regex(@"\b(test|test2)\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
return regex.Replace(input, "*");
Run Code Online (Sandbox Code Playgroud)

它工作正常.

c# regex

8
推荐指数
1
解决办法
8233
查看次数

Android WindowManager TYPE_SYSTEM_ALERT触摸布局

我的应用程序在特定时间向用户显示一个按钮TYPE_SYSTEM_ALERT,我试图让用户移动它.触摸和移动操作会在下面的代码中注册,但按钮不会移动.我错过了什么?

    //create button
    mbtRec = new Button(ACR.getContext()); 
    mbtRec.setText(R.string.start_recording);
    mbtRec.setTypeface(null, Typeface.BOLD);
    mbtRec.setBackgroundColor(Color.RED);       //mbtRec.setBackgroundResource(R.drawable.ic_launcher); 
    mbtRec.setOnClickListener(recButtonOnClickListener);
    mbtRec.setOnTouchListener(recButtonOnTouchListener);
    //create layout params
    recButtonLayoutParams = new WindowManager.LayoutParams();
    recButtonLayoutParams.flags = WindowManager.LayoutParams.FORMAT_CHANGED; //8
    recButtonLayoutParams.format = PixelFormat.RGBA_8888; //PixelFormat.TRANSLUCENT
    recButtonLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    recButtonLayoutParams.gravity = Gravity.TOP | Gravity.CENTER; //51
    recButtonLayoutParams.width = WindowManager.LayoutParams.FILL_PARENT;
    recButtonLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    paramWindowManager.addView(this.mbtRec, recButtonLayoutParams);


OnTouchListener recButtonOnTouchListener = new View.OnTouchListener() {
        @TargetApi(Build.VERSION_CODES.FROYO)
        @Override
        public boolean onTouch(View v, MotionEvent event) {
             switch(event.getActionMasked())
                {
                    case MotionEvent.ACTION_DOWN:
                        Tools.Log("Drag", "Started Dragging");
                        break;
                    case MotionEvent.ACTION_UP:
                        Tools.Log("Drag", "Stopped Dragging");
                        break;
                    case MotionEvent.ACTION_MOVE:
                        Tools.Log("Drag", "Dragging");


                        recButtonLayoutParams.x …
Run Code Online (Sandbox Code Playgroud)

android window-managers move ontouchlistener layoutparams

8
推荐指数
1
解决办法
5777
查看次数

c#缩短url的字符串

我想要独特地缩短字符串文件ID以便在像bit.ly等的网址中使用.我可以使用数据库中的ID,但我希望网址是随机的.

什么是最好的解决方案?

网站将是一个移动网站,所以我希望它尽可能短

c# bit.ly url-shortener

6
推荐指数
2
解决办法
7959
查看次数

jQuery跨域请求响应头

我正在用html数据类型制作跨域ajax请求.他们工作正常

Access-Control-Allow-Origin
Run Code Online (Sandbox Code Playgroud)

在服务器的响应中.问题是我需要从服务器的响应中获取某些标头,无论我做什么,除"内容类型"之外的响应标头返回null.

jQuery执行请求,检索包含标题的响应(我可以从流量中看到它),但它不会解析它.

我试过用

crossDomain: true
Run Code Online (Sandbox Code Playgroud)

它没有帮助.以下是来自服务器的示例响应.

Access-Control-Allow-Origin:*
Cache-Control:private
Content-Encoding:gzip
Content-Length:514
Content-Type:text/html; charset=utf-8 
X-MYRESPONSEHEADER:1
Run Code Online (Sandbox Code Playgroud)

如果请求和响应文档在同一服务器上

 success: function (data, status, xhr) {
        totalRows = xhr.getResponseHeader("X-MYRESPONSEHEADER");
Run Code Online (Sandbox Code Playgroud)

工作良好.我也尝试将$ .ajax分配给变量之类的

var jQxhr = $.ajax(.....
Run Code Online (Sandbox Code Playgroud)

我不明白为什么它不会被解析,因为jQuery实际上发出请求并获得响应

有任何想法吗?我错过了什么吗?

更新或龙的评论

标题已发送到请求

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: X-MYRESPONSEHEADER
Access-Control-Allow-Methods: POST
Access-Control-Allow-Methods: GET
X-MYRESPONSEHEADER: 24
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 29 Feb 2012 11:34:21 GMT
Run Code Online (Sandbox Code Playgroud)

内容长度:514

ajax jquery cross-domain response-headers

6
推荐指数
1
解决办法
2万
查看次数