<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Android &#8211; WANGXUCHAO.CN</title>
	<atom:link href="https://www.wangxuchao.cn/category/android/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wangxuchao.cn</link>
	<description></description>
	<lastBuildDate>Tue, 12 Mar 2024 02:56:59 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to androidx.appcompat.widget.AppCompatSpinner$SavedState</title>
		<link>https://www.wangxuchao.cn/java-lang-classcastexception-android-view-abssavedstate1-cannot-be-cast-to-androidx-appcompat-widget-appcompatspinnersavedstate/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Tue, 12 Mar 2024 02:56:59 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=162</guid>

					<description><![CDATA[今天遇到一个返回上一个Fragment闪退的问题，下面是大致代码： 第一次进入页面正常，当跳转到下一个页面，再 &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/java-lang-classcastexception-android-view-abssavedstate1-cannot-be-cast-to-androidx-appcompat-widget-appcompatspinnersavedstate/" class="more-link">继续阅读<span class="screen-reader-text">“java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to androidx.appcompat.widget.AppCompatSpinner$SavedState”</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>今天遇到一个返回上一个Fragment闪退的问题，下面是大致代码：</p>



<pre class="wp-block-code"><code>// xxx_layout.xml
&lt;layout>
    &lt;include layout="@layout/view_edit_spinner" />
    &lt;include layout="@layout/view_edit_textview" />
&lt;/layout>

// view_edit_spinner.xml
&lt;LinearLayout>
    &lt;androidx.appcompat.widget.AppCompatSpinner
            <strong><em>android:id="@+id/edit_value"</em></strong>
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
&lt;/LinearLayout>

// view_edit_textview.xml
&lt;LinearLayout>
    &lt;androidx.appcompat.widget.AppCompatTextView
            <strong><em>android:id="@+id/edit_value"</em></strong>
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
&lt;/LinearLayout></code></pre>



<p>第一次进入页面正常，当跳转到下一个页面，再返回当前页面时，会报错闪退，而且是系统平台级的，经过排查，是由于引用其他布局文件，不同控件的<strong><em>resId</em></strong> 一样，导致系统尝试恢复原来状态时类型转换错误。</p>



<p>解决方法：<strong><em>android:id=&#8221;@+id/edit_value&#8221;</em></strong> 中的id不同控件改成不一样的即可</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>RecyclerView显示所有元素，不需要包含在NestedScrollView中</title>
		<link>https://www.wangxuchao.cn/recyclerview%e6%98%be%e7%a4%ba%e6%89%80%e6%9c%89%e5%85%83%e7%b4%a0%ef%bc%8c%e4%b8%8d%e9%9c%80%e8%a6%81%e5%8c%85%e5%90%ab%e5%9c%a8nestedscrollview%e4%b8%ad/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Fri, 22 Dec 2023 03:57:11 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=159</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-code"><code>import android.content.Context
import android.util.AttributeSet
import androidx.recyclerview.widget.RecyclerView

class DynamicHeightRecyclerView(context: Context, attrs: AttributeSet) :
    RecyclerView(context, attrs) {

    override fun onMeasure(widthSpec: Int, heightSpec: Int) {
        super.onMeasure(
            widthSpec,
            MeasureSpec.makeMeasureSpec(Int.MAX_VALUE shr 2, MeasureSpec.AT_MOST)
        )
    }
}</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Android Adapter调用notifyDataSetChanged()列表不更新的问题</title>
		<link>https://www.wangxuchao.cn/android-adapter%e8%b0%83%e7%94%a8notifydatasetchanged%e5%88%97%e8%a1%a8%e4%b8%8d%e6%9b%b4%e6%96%b0%e7%9a%84%e9%97%ae%e9%a2%98/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Thu, 19 May 2022 01:11:00 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=148</guid>

					<description><![CDATA[目前发现一个Adapter调用notifyDataSetChanged()列表不更新的问题，代码如下： 原因： &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/android-adapter%e8%b0%83%e7%94%a8notifydatasetchanged%e5%88%97%e8%a1%a8%e4%b8%8d%e6%9b%b4%e6%96%b0%e7%9a%84%e9%97%ae%e9%a2%98/" class="more-link">继续阅读<span class="screen-reader-text">“Android Adapter调用notifyDataSetChanged()列表不更新的问题”</span></a></p>]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">目前发现一个Adapter调用<strong>notifyDataSetChanged()</strong>列表不更新的问题，代码如下：</pre>



<pre class="wp-block-code"><code>mChannelList = channelListBean.getList();
huodaoInfoAdapter.notifyDataSetChanged();</code></pre>



<p>原因：channelListBean.getList()和mChannelList是两个不同的变量，内存地址不同，赋值语句将新的内存地址赋给mChannelList，而Adapter中保留的list还是原来的内存地址。</p>



<p>解决方法：</p>



<pre class="wp-block-code"><code>if (!mChannelList.isEmpty()) {
  mChannelList.clear();
}
mChannelList.addAll(channelListBean.getList());

huodaoInfoAdapter.notifyDataSetChanged();</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>小米手机MIUI抓取蓝牙日志</title>
		<link>https://www.wangxuchao.cn/%e5%b0%8f%e7%b1%b3%e6%89%8b%e6%9c%bamiui%e6%8a%93%e5%8f%96%e8%93%9d%e7%89%99%e6%97%a5%e5%bf%97/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Tue, 22 Dec 2020 02:04:11 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=129</guid>

					<description><![CDATA[1.打开开发者选项，打开蓝牙调试日志和蓝牙数据包日志开关 2.在拨号盘输入一次&#160;&#160;*#*# &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/%e5%b0%8f%e7%b1%b3%e6%89%8b%e6%9c%bamiui%e6%8a%93%e5%8f%96%e8%93%9d%e7%89%99%e6%97%a5%e5%bf%97/" class="more-link">继续阅读<span class="screen-reader-text">“小米手机MIUI抓取蓝牙日志”</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>1.打开开发者选项，打开蓝牙调试日志和蓝牙数据包日志开关</p>



<p>2.在拨号盘输入一次&nbsp;&nbsp;*#*#5959#*#*&nbsp;&nbsp;即开始抓蓝牙日志</p>



<p>3.操作APP，进行蓝牙通信</p>



<p>4.再拨号盘输入一次&nbsp;&nbsp;*#*#5959#*#*</p>



<p>5.等待大概半分钟，在文件管理器中 /sdcard/MIUI/debug_log下会生成蓝牙日志文件</p>



<p>6.使用wireshark打开蓝牙日志文件</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>记录一下Fragment连续跳转2次返回首页时第三个页面还显示的问题</title>
		<link>https://www.wangxuchao.cn/%e8%ae%b0%e5%bd%95%e4%b8%80%e4%b8%8bfragment%e8%bf%9e%e7%bb%ad%e8%b7%b3%e8%bd%ac2%e6%ac%a1%e8%bf%94%e5%9b%9e%e9%a6%96%e9%a1%b5%e6%97%b6%e7%ac%ac%e4%b8%89%e4%b8%aa%e9%a1%b5%e9%9d%a2%e8%bf%98%e6%98%be/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Mon, 06 Jan 2020 14:49:38 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Fragment]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=105</guid>

					<description><![CDATA[有个需求是 “ A页面 ”跳转“ B页面 ”然后跳转“ C页面 ”。 在使用Fragment进行页面跳转的时候 &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/%e8%ae%b0%e5%bd%95%e4%b8%80%e4%b8%8bfragment%e8%bf%9e%e7%bb%ad%e8%b7%b3%e8%bd%ac2%e6%ac%a1%e8%bf%94%e5%9b%9e%e9%a6%96%e9%a1%b5%e6%97%b6%e7%ac%ac%e4%b8%89%e4%b8%aa%e9%a1%b5%e9%9d%a2%e8%bf%98%e6%98%be/" class="more-link">继续阅读<span class="screen-reader-text">“记录一下Fragment连续跳转2次返回首页时第三个页面还显示的问题”</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>有个需求是 “ A页面 ”跳转“ B页面 ”然后跳转“ C页面 ”。</p>



<p>在使用Fragment进行页面跳转的时候，第一次跳转（A-&gt;B）加.addToBackStack(null) ，第二次跳转（B-&gt;C）不加，然后点击返回按钮</p>



<p>期望状态是B、C消失，A出现</p>



<p>可是最终效果是返回到了A页面同时C页面还在，并没有被destroy，当进入另一个界面返回到A，这时候C会重新生成</p>



<p><strong>原因：</strong>点击返回键只回滚了第一次跳转（<strong>A</strong>-&gt;<strong>B</strong>）加.addToBackStack(null) ，C页面没有影响，也不会重新生成。A重新跳转到其他页面变成（<strong>A、C</strong>-&gt;<strong>B</strong>） 加.addToBackStack(null) ,返回的时候会回滚A、C两个页面的状态</p>



<p><strong>解决方案：</strong>（<strong>B</strong>-&gt;<strong>C</strong>）加.addToBackStack(null)  </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>解决Android 应用接入USB输入设备后应用重跑onCreate的问题</title>
		<link>https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android-%e5%ba%94%e7%94%a8%e6%8e%a5%e5%85%a5usb%e8%be%93%e5%85%a5%e8%ae%be%e5%a4%87%e5%90%8e%e5%ba%94%e7%94%a8%e9%87%8d%e8%b7%91oncreate%e7%9a%84%e9%97%ae%e9%a2%98/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Sat, 04 Jan 2020 08:54:39 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[USB]]></category>
		<guid isPermaLink="false">https://www.wangxuchao.cn/?p=102</guid>

					<description><![CDATA[解决方案: 在AndroidManifest.xml中, 指定activity的定义加上: android:c &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android-%e5%ba%94%e7%94%a8%e6%8e%a5%e5%85%a5usb%e8%be%93%e5%85%a5%e8%ae%be%e5%a4%87%e5%90%8e%e5%ba%94%e7%94%a8%e9%87%8d%e8%b7%91oncreate%e7%9a%84%e9%97%ae%e9%a2%98/" class="more-link">继续阅读<span class="screen-reader-text">“解决Android 应用接入USB输入设备后应用重跑onCreate的问题”</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>解决方案:</p>



<p> 在AndroidManifest.xml中, 指定activity的定义加上:  </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>  android:configChanges=&#8221;screenSize|keyboard|keyboardHidden|navigation&#8221; </p></blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>  <a href="https://blog.csdn.net/ansondroider/article/details/88238322">https://blog.csdn.net/ansondroider/article/details/88238322</a>  </p></blockquote>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MPAndroidChart 3.0.3在设置时间为x轴遇到的一些坑</title>
		<link>https://www.wangxuchao.cn/mpandroidchart-3-0-3%e5%9c%a8%e8%ae%be%e7%bd%ae%e6%97%b6%e9%97%b4%e4%b8%bax%e8%bd%b4%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%80%e4%ba%9b%e5%9d%91/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Fri, 08 Jun 2018 07:10:34 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[MPAndroidChart]]></category>
		<guid isPermaLink="false">http://www.wangxuchao.cn/?p=35</guid>

					<description><![CDATA[1.将时间戳直接放入到List&#60;Entry&#62; entries中，并且设置 entries.add( &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/mpandroidchart-3-0-3%e5%9c%a8%e8%ae%be%e7%bd%ae%e6%97%b6%e9%97%b4%e4%b8%bax%e8%bd%b4%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%80%e4%ba%9b%e5%9d%91/" class="more-link">继续阅读<span class="screen-reader-text">“MPAndroidChart 3.0.3在设置时间为x轴遇到的一些坑”</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignnone size-large wp-image-44" src="http://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-01-36-640_com.tangram.blenfc-1024x576.png" alt="" width="525" height="295" srcset="https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-01-36-640_com.tangram.blenfc-1024x576.png 1024w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-01-36-640_com.tangram.blenfc-300x169.png 300w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-01-36-640_com.tangram.blenfc-768x432.png 768w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-01-36-640_com.tangram.blenfc.png 1920w" sizes="(max-width: 525px) 100vw, 525px" /></p>
<p>1.将时间戳直接放入到List&lt;Entry&gt; entries中，并且设置</p>
<blockquote><p>entries.add(new Entry(<span style="color: #ff0000;">currTime</span>, floatValue));</p>
<p>xAxis.setGranularity(60f);</p>
<p>xAxis.setValueFormatter(new IAxisValueFormatter() {</p>
<p>private SimpleDateFormat mFormat = new SimpleDateFormat(&#8220;MM-dd HH:mm&#8221;);</p>
<p>@Override<br />
public String getFormattedValue(float value, AxisBase axis) {<br />
long timestamp = (long) (<span style="color: #ff0000;">value</span>*1000l);<br />
return mFormat.format(timestamp);<br />
}<br />
});</p></blockquote>
<p>放大的时候间隔60就不继续放大了，例如<strong>1528250160</strong>（06-06 09:56），<strong>1528250220</strong>（06-06 09:57）&#8230;&#8230;会出现两个点同时显示在一个x轴上的情况<span id="more-35"></span></p>
<p>我的解决方法：取第一个值为基础值，后面的减基础值就得到一个比较小的值，在格式化的时候再把基础值加上</p>
<blockquote><p>entries.add(new Entry(<span style="color: #ff0000;">currTime-firstTime</span>, floatValue));</p>
<p>xAxis.setValueFormatter(new IAxisValueFormatter() {</p>
<p>private SimpleDateFormat mFormat = new SimpleDateFormat(&#8220;MM-dd HH:mm&#8221;);</p>
<p>@Override<br />
public String getFormattedValue(float value, AxisBase axis) {<br />
long timestamp = (long) ((<span style="color: #ff0000;">value+firstTime</span>)*1000l);<br />
return mFormat.format(timestamp);<br />
}<br />
});</p></blockquote>
<p>显示正常了，但是发现x轴两点之间总会少一个点，导致时间隔了一分钟，当我把实际数值显示出来的时候发现原本以为x轴应该是0，60，120，180&#8230;.结果是0，100，200，300&#8230;所以60没显示，显示了120对应的label</p>
<p>解决办法：将x轴上的值再除以60得到0，1，2，3，4&#8230;.这样就没问题了</p>
<blockquote><p>entries.add(new Entry((currTime-firstTime)/60,floatValue));</p>
<p>xAxis.setGranularity(<span style="color: #ff0000;">1f</span>);</p>
<p>xAxis.setValueFormatter(new IAxisValueFormatter() {</p>
<p>private SimpleDateFormat mFormat = new SimpleDateFormat(&#8220;MM-dd HH:mm&#8221;);</p>
<p>@Override<br />
public String getFormattedValue(float value, AxisBase axis) {<br />
long timestamp = (long) ((<span style="color: #ff0000;">value*60+firstTime</span>)*1000l);<br />
return mFormat.format(timestamp);<br />
}<br />
});</p></blockquote>
<p>but,最后并没有解决，经过一番排查之后发现<code>public String getFormattedValue(float value, AxisBase axis)</code> 中的value为float类型，我进行计算 <code>(long) (value*1000l);</code>的时候最后3位数出现了其他的数据，处理方法<code>(long) ((int)value*1000l);</code></p>
<p><img decoding="async" class="alignnone wp-image-43 size-large" src="http://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-02-46-711_com.tangram.blenfc-1024x576.png" alt="" width="525" height="295" srcset="https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-02-46-711_com.tangram.blenfc-1024x576.png 1024w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-02-46-711_com.tangram.blenfc-300x169.png 300w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-02-46-711_com.tangram.blenfc-768x432.png 768w, https://www.wangxuchao.cn/wp-content/uploads/2018/06/Screenshot_2018-06-08-16-02-46-711_com.tangram.blenfc.png 1920w" sizes="(max-width: 525px) 100vw, 525px" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>解决Android中通过glReadPixels获取像素颜色不对的问题</title>
		<link>https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android%e4%b8%ad%e9%80%9a%e8%bf%87glreadpixels%e8%8e%b7%e5%8f%96%e7%9a%84%e9%a2%9c%e8%89%b2%e4%b8%8d%e5%af%b9%e7%9a%84%e9%97%ae%e9%a2%98/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Sun, 29 Oct 2017 20:00:41 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[glReadPixels]]></category>
		<guid isPermaLink="false">http://www.wangxuchao.cn/?p=17</guid>

					<description><![CDATA[if (YayoGameMidlet.shotScreen) { // GL to Android Bitma &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android%e4%b8%ad%e9%80%9a%e8%bf%87glreadpixels%e8%8e%b7%e5%8f%96%e7%9a%84%e9%a2%9c%e8%89%b2%e4%b8%8d%e5%af%b9%e7%9a%84%e9%97%ae%e9%a2%98/" class="more-link">继续阅读<span class="screen-reader-text">“解决Android中通过glReadPixels获取像素颜色不对的问题”</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><code><br />
if (YayoGameMidlet.shotScreen) {<br />
// GL to Android Bitmap Color Modifier values.<br />
final float[] cmVals = {<br />
0, 0, 1, 0, 0,<br />
0, 1, 0, 0, 0,<br />
1, 0, 0, 0, 0,<br />
0, 0, 0, 1, 0,<br />
};</code><span id="more-17"></span></p>
<p>// Collect the pixels from the GLSurfaceView.<br />
int x = 0;<br />
int y = 0;<br />
int w = YayoGameMidlet.screenWidth;<br />
int h = YayoGameMidlet.screenHeight;<br />
int[] pix = new int[w * h];<br />
IntBuffer PixelBuffer = IntBuffer.wrap(pix);<br />
PixelBuffer.position(0);<br />
gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, PixelBuffer);<br />
Bitmap glBitmap = Bitmap.createBitmap(pix, w, h, Bitmap.Config.ARGB_8888);<br />
PixelBuffer = null;<br />
pix = null;</p>
<p>// Translate pixel colors to make them android compatible.<br />
Paint paint = new Paint();<br />
paint.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(cmVals)));<br />
Bitmap newImage = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);<br />
Canvas canvas = new Canvas(newImage);<br />
canvas.drawBitmap(glBitmap, 0, 0, paint);<br />
glBitmap.recycle();<br />
glBitmap = null;</p>
<p>// Generate the overlay from the modified pixels with the help of a matrix.<br />
Matrix matrix = new Matrix();<br />
matrix.preScale(1.0f, -1.0f); // Vertical flip.<br />
YayoGameMidlet.screenBmp = Bitmap.createBitmap(newImage, 0, 0, newImage.getWidth(), newImage.getHeight(), matrix, true);<br />
newImage.recycle();<br />
newImage = null;</p>
<p>// Done capturing overlay.<br />
YayoGameMidlet.shotScreen = false;<br />
}</p>
<p><a href="https://www.programcreek.com/java-api-examples/index.php?class=javax.microedition.khronos.opengles.GL10&amp;method=glReadPixels" target="_blank" rel="noopener">参考链接</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用URLConnection中getContentLength()得到-1的解决办法</title>
		<link>https://www.wangxuchao.cn/urlconnection-getcontentlength-1/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Thu, 28 Sep 2017 08:15:50 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<guid isPermaLink="false">http://www.wangxuchao.cn/?p=9</guid>

					<description><![CDATA[URL myURL = new URL(fileurl); URLConnection conn = myUR &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/urlconnection-getcontentlength-1/" class="more-link">继续阅读<span class="screen-reader-text">“使用URLConnection中getContentLength()得到-1的解决办法”</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>URL myURL = new URL(fileurl);</p>
<p>URLConnection conn = myURL.openConnection();</p>
<p>conn.setRequestProperty(&#8220;Accept-Encoding&#8221;, &#8220;identity&#8221;); // 添加此行代码，告诉服务器不要压缩，那么这个-1的问题就能解决了</p>
<p>conn.connect();</p>
<p>allfilelenth = conn.getContentLength();// 根据响应获取文件大小</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
