我收到了这个错误
java.io.IOException: Content-Length and stream length disagree
Run Code Online (Sandbox Code Playgroud)
在这行代码上 return response.body().bytes();
这是完整的代码
编辑:在一些谷歌之后,错误的原因来自okhttp lib
if (contentLength != -1L && contentLength != bytes.size.toLong()) {
throw IOException(
"Content-Length ($contentLength) and stream length (${bytes.size}) disagree")
}
Run Code Online (Sandbox Code Playgroud)
但是如何解决这个问题?
编辑:
这是完整的代码:
public class OkHttpHandler extends AsyncTask<Void, Void, byte[]> {
private final String Fetch_URL = "http://justedhak.comlu.com/get-data.php";
ArrayList<Listitem> Listitem;
int resulta;
OkHttpClient httpClient = new OkHttpClient();
String myJSON;
JSONArray peoples = null;
InputStream inputStream = null;
@Override
protected byte[] doInBackground(Void... params) {
Log.d("e", "dddddddddd");
Log.d("e", Fetch_URL);
Request.Builder …Run Code Online (Sandbox Code Playgroud) 我想将系统表user_tab_cols中的一些数据保存到临时表中,以便从中获取转储.
其中有100,000行,我从user_tab_cols中选择了大约1,000条记录,并使用此查询将它们保存到临时表中:
create table temp table as
select * from user_tab_cols where condition...
Run Code Online (Sandbox Code Playgroud)
我有错误'非法使用longtype',因为列DATA_DEFAULT包含long类型.
有没有一种改变方式,我可以将长型存储到anotehr表中?
我在Android开发人员上使用Volley跟踪图像兑现教程,我遇到了请求图像请求并缓存它的问题,我想因为我创建的singelton(从教程中复制).
我的Eclipse给出了错误,getInstance(this)因为这是上下文,我想要一个图像.
ImageRequest request = new ImageRequest(
url,
new Response.Listener<Bitmap>() {
@Override
public void onResponse(Bitmap bitmap) {
mNetworkImageView = (NetworkImageView) findViewById(R.id.ImageView);
mImageLoader = MySingleton.getInstance(this).getImageLoader();
mNetworkImageView.setImageUrl(IMAGE_URL, mImageLoader);
// mImageLoader = MySingleton.getInstance(this).getImageLoader();
// mImageLoader.get(IMAGE_URL, ImageLoader.getImageListener(mImageView,
// R.drawable.ic_launcher, R.drawable.ic_launcher));
}
},
0,
0,
null,
new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
// mImageView.setImageResource(R.drawable.ic_launcher);
}
});
MySingleton.getInstance(this).addToRequestQueue(request);
Run Code Online (Sandbox Code Playgroud)
这是单身人士:
package com.example.p;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
public class MySingleton …Run Code Online (Sandbox Code Playgroud) 我有以下错误Hostname domain.com not verified:不是"javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated"我以前能够连接到不同的主机,在这个主机我遇到问题,如何解决它
javax.net.ssl.SSLPeerUnverifiedException: Hostname domain.com not verified:
certificate: sha1//WQM9QbrKs6DCFa9qN/EIw1ywBw=
DN: CN=*.ipage.com,OU=Domain Control Validated - RapidSSL(R),OU=See www.rapidssl.com/resources/cps (c)14,OU=GT29505539
subjectAltNames: [*.ipage.com, ipage.com]
at com.squareup.okhttp.Connection.connectTls(Connection.java:244)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:199)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
Run Code Online (Sandbox Code Playgroud)
这是我的代码
try {
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
jsonObject.accumulate("password", pass);
jsonObject.accumulate("email", emails);
json = jsonObject.toString();
Log.e("MYAPP", "getjson");
} catch (JSONException e) {
Log.e("MYAPP", "unexpected JSON exception", e);
}
try{
RequestBody formBody = new …Run Code Online (Sandbox Code Playgroud) 用于配置文件的CONNECT_TIME的定义,根据oracle 文档
CONNECT_TIME
指定会话的总运行时间限制,以分钟为单位.
我猜他们所说的连接时间是整个过程执行的时间.
有没有办法限制在过程中执行查询的连接时间?例如,如果过程有3个执行查询,并且任何查询超过指定的时间限制,则应中止或终止该会话.
老实说,在询问之前我对此进行了一些搜索。如何从活动接收意图fragmentactivity我正在尝试使用viewpager。我在获取参数时遇到错误Bundle extras = getArguments();
public class SingleViewActivity extends FragmentActivity {
ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page_view);
ArrayList<Listitem> personArrayList = new ArrayList<Listitem>();
// Listitem item = new Listitem("1", "http://developer.android.com/assets/images/android_logo.png");//I used to add it staticly
Bundle extras = getArguments();
if (extras != null) {
extras = extras.getParcelableArrayList(ARG_PERSON_LIST);
personArrayList.add(item); }
// DemoObjectFragment f = DemoObjectFragment.newInstance(personArrayList);
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
Log.d("s", "singleview");
DemoCollectionPagerAdapter mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter( getSupportFragmentManager(),personArrayList);
mViewPager.setAdapter(mDemoCollectionPagerAdapter);
Run Code Online (Sandbox Code Playgroud) 这是我第一次使用onscroll监听器.我的问题是每次向下滚动时如何获取20个新行?
我理解当我向下滚动网格视图时,将执行此代码.
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
this.currentFirstVisibleItem = firstVisibleItem;
this.currentVisibleItemCount = visibleItemCount;
this.totalItem = totalItemCount;
if ((totalItemCount - visibleItemCount) <= (firstVisibleItem + 20)) {
// the below when executed will get all the rows ,I only need 20 rows
handler.execute().get();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码
// the load more in the grid view, fetch new images.
mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
private int currentVisibleItemCount;
private int currentScrollState;
private int currentFirstVisibleItem;
private int …Run Code Online (Sandbox Code Playgroud) 我如何只获得当前时间?
select getdate()
Run Code Online (Sandbox Code Playgroud)
给我:
Dec 16 2016 5:41PM
Run Code Online (Sandbox Code Playgroud)
我想要这个结果:
5:41PM
Run Code Online (Sandbox Code Playgroud) 如何将uri图像的路径发送到另一个活动并将其转换为图像.我试过以下
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK && data != null && data.getData() != null) {
//file name
Uri selectedImage = data.getData();
Intent i = new Intent(this,
AddImage.class);
i.putExtra("imagePath", selectedImage);
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
并得到这样的
String imagePath = getIntent().getStringExtra("imagePath");
imageview.setImageURI(Uri.parse(imagePath ));
Run Code Online (Sandbox Code Playgroud)