Jsoup,HTTPClient,HttpURLConnection。(Jsoup, HTTPClient, HttpURLConnection. How to get a response html, if the server always returns a 413 error code)
当向http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=[request string]服务器发送GET请求时,始终响应413错误。 在浏览器中,此请求显示带有javascript重定向的html页面。 但是在Jsoup中获取此URL时抛出异常。 我认为这是为了防止自动登录。我想得到响应的html宽度Jsoup。
try{ Response response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET).execute(); } catch (HttpStatusException e) { //? What i must write here to get response }
在C#/。Net HttpWebRequest Exception对象中包含Response,我可以从中提取html数据。 如何在java / android中做到这一点?
对不起我的英语不好。
When sending a GET request to http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=[request string] server always response 413 error. In browser this request show html page with javascript redirect. But in Jsoup when get this URL throwed exception. I think this is to prevent automated login.I want to get responsed html width Jsoup.
try{ Response response = Jsoup.connect("http://blahblahblah.com/site/Login/?domain=blahblahblah.com&request=abc123").method(Method.GET).execute(); } catch (HttpStatusException e) { //? What i must write here to get response }
In C#/.Net HttpWebRequest Exception object contain Response and I can extract html data from it. How to do it in java / android?
Sorry for my English.
原文:https://stackoverflow.com/questions/19958836
最满意答案
就可访问的API而言,听起来你已经找到了相关的点点滴滴。 如果您还没有,请阅读此stackoverflow项目 。
使用Choreographer和外推,您可以猜测下一次显示刷新的时间。 在Android 5.0+设备上使用
eglPresentationTimeANDROID()
,您可以在需要将特定帧发送到显示器时告诉SurfaceFlinger。 假设SurfaceFlinger正确考虑了所有延迟(例如“智能”面板添加的额外帧),那么应该可以获得可靠的时序。(请记住,时间基于显示器锁定下一帧的时间,而不是下一帧在显示器上完全可见时...时间延迟取决于面板。)
Grafika的 “预定交换”活动使用此功能,但听起来你已经熟悉了。
当它进行交换时,显示器发出信号的唯一方法是从前一帧中
dup()
displaydup()
display-retire fence fd,然后等待它。 SurfaceFlinger中的一些代码执行此操作,特别是DispSync监视退役围栏以查看软件“VSYNC”是否正在漂移。 没有用于围栏的公共API,并且用户空间响应时间肯定可能超过1毫秒......它通常比预先做好反应更好。 您对非root用户非自定义设备的要求会导致此问题。如果您大多看到正确的行为,但偶尔会看到错过,您最好的选择是使用systrace来追踪原因。
As far as accessible APIs go, it sounds like you've found the relevant bits and pieces. If you haven't yet, please read through this stackoverflow item.
Using Choreographer and extrapolation, you can guess at when the next display refresh will occur. Using
eglPresentationTimeANDROID()
on an Android 5.0+ device, you can tell SurfaceFlinger when you want a particular frame to be sent to the display. Assuming SurfaceFlinger is properly accounting for all latency (such as additional frames added by "smart" panels), that should get you reliable timing.(Bear in mind that the timing is based on when the display latches the next frame, not when the next frame is fully visible on the display... the latency there will depend on the panel.)
Grafika's "scheduled swap" Activity uses this feature, but it sounds like you're already familiar.
The only way to get signaled by the display when it does the swap would be to
dup()
the display-retire fence fd from the previous frame, and wait on it. Some of the code in SurfaceFlinger does this, notably DispSync watches the retire fences to see if the software "VSYNC" is drifting. There is no public API for fences, and the user-space response time could certainly be more than 1ms anyway... it usually works out better to schedule ahead than it does to react. Your requirement for non-rooted non-custom devices makes this problematic.If you're mostly seeing correct behavior, but occasionally seeing a miss, your best bet is to use systrace to track down the cause.
相关问答
更多-
触摸屏幕后如何进入下一个活动3次[关闭](How to go to next activity after touching the screen exact 3 times [closed])[2023-02-18]
你必须管理相同的计数。 做这个: int touchCount = 0; ImageView img = (ImageView) findViewById(R.id.image); img.setOnClickListener(new OnClickListener() { public void onClick(View v) { touchCount = touchCount + 1; if (touchCount == 3){ to ... -
您应该将变换应用于父视图(您的UIWindow)。 旋转可以使用CGAffineTransformMakeRotation() 。 实际上允许设备方向可以引起旋转,但可能会更好。 在应用程序设置设置,该应用程序支持自动旋转,然后在UIViewController返回ü -(BOOL)shouldAutorotateToInterfaceOrientation旋转传入时UIInterfaceOrientationPortraitUpsideDown You should apply a transform t ...
-
重新启动活动后,将布尔值设置为true 。 重启完成后将其设置为false 。 仅当startActivity为false时才调用startActivity 。 声明一个字段: private boolean mRestarted = false; 在restartActivity : void restartActivity() { if(!mRestarted} { Intent intent = getIntent(); finish(); st ...
-
我认为此链接对您有所帮助。 尝试一下,我相信它会清除你的怀疑:))) I think this link will be helpful to you. Try it and I'm sure it will clear out your doubts :)))
-
就可访问的API而言,听起来你已经找到了相关的点点滴滴。 如果您还没有,请阅读此stackoverflow项目 。 使用Choreographer和外推,您可以猜测下一次显示刷新的时间。 在Android 5.0+设备上使用eglPresentationTimeANDROID() ,您可以在需要将特定帧发送到显示器时告诉SurfaceFlinger。 假设SurfaceFlinger正确考虑了所有延迟(例如“智能”面板添加的额外帧),那么应该可以获得可靠的时序。 (请记住,时间基于显示器锁定下一帧的时间,而 ...
-
所以我添加了一个Hack来使这个工作在Tab4上。 在应用旋转功能结束时,我添加了以下代码。 // hack for the Tab 4 new CountDownTimer(mFlipAnimationTime * 2, 33) { @Override public void onTick(long millisUntilFinished) { mFlipView.refreshDrawableState(); ...
-
在AndroidManifest.xml文件的
元素中设置android:screenOrientation="landscape" 。 Set android:screenOrientation="landscape" in the element of your AndroidManifest.xml file. -
微调器的默认背景是9-patch drawable ,因此它可以相应缩放。 如果要反转箭头,则必须复制绘图并手动反转。 在这里,我采用了Lollipop 1上发现的旋转器的背景并垂直翻转: 您可以复制该文件并将其作为9补丁(即扩展名为.9.png (不仅仅是.png ))保存到drawable-xxxhdpi文件夹中。 1 [android-sdk] /platforms/android-22/data/res/drawable-xxxhdpi/spinner_mtrl_am_alpha.9.png 从Ma ...
-
翻转动画(Flip Up Animation)[2022-07-01]
你可以通过编程来完成。 这里是Xamarin的C#。 目前无法测试Java,但它会非常相似。 ImageView block = FindViewById(Resource.Id.imgBlock); ObjectAnimator blockSpin = ObjectAnimator.OfFloat(block, "rotationX", 0, 360); imageCard.PivotX = 0.5f; //so it spins on center float scale = m ... -
CardView翻转动画(CardView flip animation)[2022-04-01]
我创建了一个包含一系列有用小部件的Android库 - 它叫做UsefulViews 。 其中一个小部件是FlippableView 。 您可以查看Javadoc以了解它是如何工作的。 I've made an Android library that contains a collection of useful widgets - it's called UsefulViews. One of these widgets is the FlippableView. You can have a look ...