小编MTA*_*MTA的帖子

HttpClient.execute总是给出Exception

我尝试使用Web的HTML,我使用此代码执行此操作:

HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();
    HttpGet httpGet = new HttpGet("http://www.google.com");
    HttpResponse response;
    try {
        response = httpClient.execute(httpGet, localContext);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

并且总是在response = httpClient.execute(httpGet, localContext);它给我例外,也在我尝试的其他代码

java android httpclient

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

MPMusicPlayerController不能在后台播放

我在我的应用程序中使用MPMusicPlayerController,当我进入后台时它停止播放.

这就是我添加它的方式:

musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c mpmusicplayercontroller

0
推荐指数
1
解决办法
2657
查看次数

谷歌Cookie解码

我开发了一些基于Google服务的东西.

现在我注意到他们在他们的服务中添加了一个sessionid,现在我也需要找到它.

我做了很多搜索,我注意到他们保存了一个名为" SID" 的cookie ,所以我认为它是.

Set-Cookie: SID=DQAAALgAAABk20DNISbQnTIm0DHuZIhhJyMg3Gs9i1gxXZrlzfc66Fq05cxvpHShc1pcFzcW0bnFLcROwZSgoiECL2J-_tJ8iGkKh25GYutor0HD15DFjMO_HeUoG4MmrKR3WO8ShxWP624YY_l_sFES6RJzhUHQtvUk0AGtscU7XodCqDjL_7XZXhCsJlBEjB09PYxyxlbEx76ebiMYop-vIx47sTmV-ygoqFaxUfmAnRja9mMbNAu8c_XbQ8Gr9UM0QuviKsE;Domain=.google.com;Path=/;Expires=Thu, 07-Apr-2022 09:48:05 GMT
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果他们是一种方式你将cookie中写入的内容解码为一个数字(因为会话ID是一个数字)

google-app-engine

0
推荐指数
1
解决办法
2784
查看次数

XCode 4.5分析工具

我构建了一个iPhone应用程序并注意到XCode中有Analyze工具.

我有这个代码:

View * view = [[View alloc]initWithFrame:self.view.frame title:currentItem.name id:currentItem.idStr];
self.menuView = [[MenuView alloc]init];
self.menuView.contentView = view;
[view release];
Run Code Online (Sandbox Code Playgroud)

View财产:

@property (retain,nonatomic) MenuView * menuView;
Run Code Online (Sandbox Code Playgroud)

当我对项目进行分析时,我得到了这个潜在的泄漏警告.我想知道它是否正常,分析只是警告我?或者我犯了错误的代码.


编辑

如果我做这样的事情:

@property (retain, nonatomic) IBOutlet UISlider *progressSlider;
Run Code Online (Sandbox Code Playgroud)

.

self.progressSlider = [[[UISlider alloc]initWithFrame:CGRectMake(58, 12, 191, 23)]autorealese];
[view addSubview:self.progressSlider];
Run Code Online (Sandbox Code Playgroud)

在dealloc中:

[progressSlider realese];
Run Code Online (Sandbox Code Playgroud)

这也是我应该做的事情?或者这是错的?

memory-leaks objective-c ios

0
推荐指数
1
解决办法
123
查看次数

MediaElement 在暂停模式下设置位置

我使用这种方法在我的MediaElement:

TimeSpan t = TimeSpan.FromSeconds(newSecond);
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
    mediaElement1.Position = TimeSpan.FromSeconds(newSecond);
});
Run Code Online (Sandbox Code Playgroud)

当用户播放视频然后暂停它并寻找新位置时,视频帧停留在前一帧。

我想知道是否有可能当我寻找新位置并且视频处于暂停模式时,帧将移动到新位置并且不会等到我再次按下播放键。

c# silverlight wpf windows-phone

0
推荐指数
1
解决办法
3562
查看次数

将NSDate转换为NSString时间问题

我有这个NSDate:

2013-03-14 17:35:00 +0000
Run Code Online (Sandbox Code Playgroud)

我尝试将其转换为NSString:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:ss"];
[formatter stringFromDate:item.startdate];
Run Code Online (Sandbox Code Playgroud)

而我得到的是:

03/14/2013 05:35:00
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题,以便在日期中给出与时间相关的日期?

iphone objective-c ios

0
推荐指数
1
解决办法
2990
查看次数

MySqlDataReader关闭连接

这是我在MySql中从表中选择数据的代码:

            MySqlDataReader msdr;

            MySqlConnection connect = new MySqlConnection(connectionStringMySql);
            MySqlCommand cmd = new MySqlCommand();

            string commandLine = "SELECT id,token FROM Table WHERE id = @id AND token = @token;";

            cmd.CommandText = commandLine;

            cmd.Parameters.AddWithValue("@id", id);
            cmd.Parameters.AddWithValue("@token", token);

            cmd.Connection = connect;
            cmd.Connection.Open();

            msdr = cmd.ExecuteReader();

            //do stuff.....

            msdr.Close();
            cmd.Connection.Close();
Run Code Online (Sandbox Code Playgroud)

正如你所看到我关闭这两个:

        msdr.Close();
        cmd.Connection.Close();
Run Code Online (Sandbox Code Playgroud)

我想问我是否需要关闭这两个?或者只关闭它就可以了cmd.Connection.Close();

我问它的原因是因为有时候当我尝试在表格中选择数据时我会收到此错误: Details: MySql.Data.MySqlClient.MySqlException: Too many connections

我想知道是不是因为我没有关闭这种联系.

.net c# mysql iis

0
推荐指数
1
解决办法
3625
查看次数

连接数过多异常

我尝试SELECT在表上运行MySql,但收到​​此错误:

Server Error in '/MyApp' Application.
Too many connections
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Too many connections
Run Code Online (Sandbox Code Playgroud)

来源错误:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack …
Run Code Online (Sandbox Code Playgroud)

.net c# mysql

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

计算html页面上的所有<a>

我想通过此方法<a>Html页面获取所有标记JavaScript:

function() {
    var links = document.getElementsByTagName('a');
    var i=0;
    for (var link in links){i++;}
    return i;
}
Run Code Online (Sandbox Code Playgroud)

我注意到它不会返回正确数量的标签.

知道什么可以解决问题吗?

知道是否还有其他方法可以获得所有的href Html

编辑

我在这个html上试过这个方法:http://mp3skull.com/mp3/nirvana.html.我得到了这个结果:"1".但页面中有更多结果.

html javascript

0
推荐指数
1
解决办法
8036
查看次数

UIView transitionFromView更改视图高度

我使用此代码在2之间进行更改UIView:

UIViewAnimationOptions animationType = UIViewAnimationOptionTransitionFlipFromLeft;

[UIView transitionFromView:self.playlistTableView toView:self.playerView duration:0.5 options:animationType completion:^(BOOL finished){
     [self.containerView sendSubviewToBack:self.upperView];
     [self.containerView sendSubviewToBack:self.playerView];

     self.isPlaylistVisible = !self.isPlaylistVisible;
     isControlsHidden = NO;
}];
Run Code Online (Sandbox Code Playgroud)

而且我注意到一种奇怪的行为,当我将翻转的高度调整为self.playerView20px并且在一秒之后,它会增加回到正常的帧大小.

我尝试更改animationTypeUIViewAnimationOptionLayoutSubviews,现在当我在视图之间切换时,不会发生此行为.知道可能是什么问题吗?

objective-c uiview ios

0
推荐指数
1
解决办法
276
查看次数