小编And*_*oid的帖子

Android HTTPS异常连接由同行重置

我正在开发一个从Web服务器下载数据的应用程序.它似乎在开始时没有任何问题地下载数据,但是几天前我开始收到这种例外:javax.net.ssl.SSLException: Read error: ssl=0x7a6588: I/O error during system call, Connection reset by peer我不确定是什么原因引起的问题,我该如何解决这个问题.以下是整个LogCat信息:

12-12 11:43:27.950: W/System.err(22010): javax.net.ssl.SSLException: Read error: ssl=0x7a6588: I/O error during system call, Connection reset by peer
12-12 11:43:27.960: W/System.err(22010):    at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
12-12 11:43:27.960: W/System.err(22010):    at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:788)
12-12 11:43:27.960: W/System.err(22010):    at org.apache.harmony.luni.internal.net.www.protocol.http.ChunkedInputStream.read(ChunkedInputStream.java:50)
12-12 11:43:27.960: W/System.err(22010):    at java.io.InputStream.read(InputStream.java:157)
12-12 11:43:27.960: W/System.err(22010):    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:225)
12-12 11:43:27.960: W/System.err(22010):    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:178)
12-12 11:43:27.960: W/System.err(22010):    at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:174)
12-12 11:43:27.960: W/System.err(22010):    at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
12-12 11:43:27.970: W/System.err(22010):    at java.io.FilterInputStream.read(FilterInputStream.java:133)
12-12 …
Run Code Online (Sandbox Code Playgroud)

connection https android

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

位图decodeStream OutOfMemory Exception

ViewFlow在我的应用程序中使用自己的Android实例.我正在从Web服务下载加密图像,而不是将它们保存在SD卡上.我正在使用viewflow来动态解密图像并显示它们.但问题是,当用户开始更快地更改图像时,它会给我一个OutOfMemoryException信息,而我发现/测试的所有信息对我的情况都不起作用.这是我正在使用的:

 @Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.image_item, null);
    }

    try {
        File bufferFile = new File(ids.get(position));
        FileInputStream fis   = new FileInputStream(bufferFile);

        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
        SecretKeySpec keySpec = new SecretKeySpec("01234567890abcde".getBytes(), "AES");
        IvParameterSpec ivSpec = new IvParameterSpec("fedcba9876543210".getBytes());
        cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
        CipherInputStream cis = new CipherInputStream(fis, cipher);

        BitmapFactory.Options o = new BitmapFactory.Options();
        final int REQUIRED_SIZE=300*1024;

        //Find the correct scale value. It should be the power of …
Run Code Online (Sandbox Code Playgroud)

android bitmap out-of-memory

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

Android AlertDialog指定的子级已有父Exception

我的申请有点问题AlertDialog.我正在显示一个AlertDialog用户可以更改他刚刚按下的按钮的文本.当我第一次这样做时没有问题,但是如果我再次按下按钮,我的应用程序会崩溃并出现标题中的异常.这是我正在使用的代码:

public void createDialog(){
     new AlertDialog.Builder(Settings.this)
    .setTitle("Stampii Server Name")
    .setView(input)
    .setPositiveButton("Set Name", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String serverName = input.getText().toString();
            server.setText(serverName);
        }
    })
    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    }).show();
}


server.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        createDialog();
    }
});
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决这个问题?我看过类似的问题,但找不到合适的解决方案.

提前致谢!

android android-alertdialog

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

Java强制转换为枚举类型问题

将Java long类型转换为Enum类型时出现了一些问题,无法找到解决方法.

这是我正在使用的:

public enum DataType {
    IMAGES(1),
    VIDEOS(2);

    private int value;
    private DataType(int i){
        this.value = i;
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要做这样的事情:

DataType dataType;
String thiz = "1";
long numb = Long.parseLong(thiz);
dataType = numb;
Run Code Online (Sandbox Code Playgroud)

我得到的错误说:

将numb转换为DataType或将dataType转换为long.

第二种情景:

我有这个 :

static String[] packetType;
String tmp=incomingData.toString(); // where incomingData is byte[]
int lastLoc = 0;
int needsSize = packetFieldSizes[tmpCurrentField-1]; // where packetFieldSizes,tmpCurrentField are integers.
thiz=tmp.substring(lastLoc, needsSize);    

packetType=thiz;  // packetType = thiz copy; where thiz is the same as used above.
Run Code Online (Sandbox Code Playgroud)

我试图将thiz转换为String []并使用valueOf,但是 …

java enums casting primitive-types long-integer

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

Objective C to Java:NSOperationQueue?

我正在尝试理解Objective C代码,我陷入了困境

码:

NSOperationQueue *queue = [[NSOperationQueue alloc] init];
Run Code Online (Sandbox Code Playgroud)

我知道这一行构造了一个类的新实例NSOperationQueue.但是这个例子NSOperationQueue做了什么?任何人都可以向我解释一下吗?由于我对Java更熟悉,如果有人能用Java建议我一段相同的代码,那将会非常有帮助.

java objective-c

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

从另一个JSONObject - Android获取ID的JSONObject

我在解析从Web服务器获取的JSON字符串时遇到了一些问题.所以我的JSON看起来像这样:

{
 ..........
"statistics":{
              "660":{
                       "param_id":660,
                       "cat_id":2,
                       "param_title":"Number",
                       "param_value":"26",
                       "value_type":"singleline",
                       "elem_order":"1"}

            ,
              "662":{
                       "param_id":662,
                       "cat_id":2,
                       "param_title":"Name",
                       "param_value":"Dani",
                       "value_type":"singleline",
                       "elem_order":"2"
                    }
                    // --||--
           }
}
Run Code Online (Sandbox Code Playgroud)

所以我得到一个JSONObject statisics,我想从中获取JSONObjects statistics,但问题是他们的名字每次都不同.所以我不能这样做json.getJSONObject("660");.那么任何建议我该怎么做?

android json

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

Android将String转换为byte [] - 将片段[]转换为片段

我有一个小问题.如何byte array将其分成几部分并保存为String.我的意思是如果y字节数组太大,我怎么能从它创建几个字符串.举个例子,我第一次只得到50比特/字节的字节,第二次得到下一个50等等.任何想法?

string android bytearray

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

Android从SD卡获取图像

我正在使用一个代码来列出我设备中的所有图像......我正试图弄清楚如何仅从特定文件夹获取图像,而不是所有图像.这是我正在使用的代码:

ArrayList<Bitmap> images = new ArrayList<Bitmap>();
String[] projection = {MediaStore.Images.Thumbnails.DATA};
Uri uri = Uri.parse("content://media/external/images/media");
cursor = managedQuery( uri, projection, null, null, null);
//cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
Log.i("MediaStore.Images.Media.EXTERNAL_CONTENT_URI", "MediaStore.Images.Media.EXTERNAL_CONTENT_URI: " + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if(cursor.getCount()==0){
     Log.i("No Cards","No Cards");
     cursor.close();
 } else if(cursor.getCount()>0){        
 for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()){
     int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
     String imagePath = cursor.getString(columnIndex);
     Log.i("imagePath", "imagePath: " + imagePath);
     Bitmap b = BitmapFactory.decodeFile("/Stampii" + imagePath, null);
     images.add(b);
  }
  }
Run Code Online (Sandbox Code Playgroud)

我想要做的是从imagePath: /mnt/sdcard/Stampii/MediaCategory-251.jpgStampii文件夹中获取图像,但我无法理解如何输入该文件夹的正确路径.我已经尝试过了:

Uri uri = Uri.parse("content://media/external/images/media/mnt/sdcard/Stampii");
Run Code Online (Sandbox Code Playgroud)

有解决方案吗

storage android internal android-sdcard

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

Android Https 状态代码-1

HttpsUrlConnection我正在通过或HttpUrlConnection根据设置从我的 Android 应用程序连接到网络服务器。目前我没有遇到任何问题,但昨天我开始收到http/https status回复-1。即使存在某种错误,网络服务器也无法返回给我。我连接的服务器被设计为在出现某种问题时errorCode返回。errorString这是我正在使用的代码,但我认为问题不在这里。

    public void UseHttpConnection(String url, String charset, String query) {
    try {
        HttpURLConnection connection = (HttpURLConnection) new URL(url)
                .openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Charset", charset);
        connection.setRequestProperty("Content-Type",
                "application/x-www-form-urlencoded;charset=" + charset);
        OutputStream output = null;
        try {
            output = connection.getOutputStream();
            output.write(query.getBytes(charset));
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (output != null)
                try {
                    output.close();
                } catch (IOException logOrIgnore) {
                }
        }

        int status = ((HttpURLConnection) connection).getResponseCode();
        Log.i("", …
Run Code Online (Sandbox Code Playgroud)

android http-status-codes httpurlconnection

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

Android获取所有可用的存储设备

是否有任何功能/方法可以使用其名称来检测手机的各种不同存储方式。我的意思是检测设备上是否有多个内部/外部存储。以及如何检测是否有可用的SD卡?

提前致谢!

android android-sdcard

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