首页
\
问答
\
PreferenceManager.getDefaultSharedPreferences中的上下文用于什么?(What is context in PreferenceManager.getDefaultSharedPreferences used for?)
PreferenceManager.getDefaultSharedPreferences中的上下文用于什么?(What is context in PreferenceManager.getDefaultSharedPreferences used for?)
鉴于传递给PreferenceManager.getDefaultSharedPreferences的任何非空上下文将返回相同的结果,PreferenceManager使用的上下文是什么,以及在不同上下文中传递的点是什么?
Given that any non-null context passed to PreferenceManager.getDefaultSharedPreferences will return the same result, what is context used for by PreferenceManager and what's the point of passing in different context?
原文:https://stackoverflow.com/questions/41554923
更新时间:2024-03-22 13:03
最满意答案
解决。 我只为文件传输创建了第二个套接字。
Resolved. I created second socket for file transfer only.
相关问答
更多-
想学java 的socket ,怎么学?[2022-05-23]
lz只是为了用java的socket啊,那么我给你这么介绍下,你学了java的基础语法后,你得掌握下java的多线程,因为 java的socket几乎是和多线程一起使用的,对于socket还要学习的就是流了这是socket传输内容的东西。如果lz学会了这两个东西,那么恭喜你,你可以学习socket的api了,学习socket的api在网上的文档还是有的,但是你得分辨哪些是好的,哪些是转载的,对于socket的学习建议lz不要看什么视频了因为网上的视频都太简单了,就类似于刚想java的时候的hello wor ... -
解决。 我只为文件传输创建了第二个套接字。 Resolved. I created second socket for file transfer only.
-
readLine(); 会读取(或阻止),直到遇到换行符,这就是你被卡住的原因。 但是你没有在你发送的命令中使用换行符,这是可疑的,因为协议中必须有一些约定的形式才能分开命令( flush()是不够的)。 我怀疑绘图仪仍在等待你用\n完成你的命令,然后才能读取它返回的任何内容。 readLine(); will read (or block) until it encounters a line feed, so that's why you're getting stuck. However you di ...
-
readLine()在读取回车符或换行符时才会返回,这是您从终端或文本文件读取时通常会得到的内容。 如果POP服务器实际上并没有在其邮件的末尾加上\ r \ n,我不会感到惊讶。 尝试使用read()。 readLine() won't return until it's read a carriage return or a line feed, which is what you normally get when you read from a terminal or a text file. I w ...
-
至少: 从Socket.setSoTimeout() javadoc接收异常并不意味着套接字总是死的: 如果超时到期[例如,在读取时,会引发java.net.SocketTimeoutException,尽管Socket仍然有效。 套接字的关闭标志似乎只在Socket.close()方法时设置,所以我不会依赖它。 At least: Receiving an exception does NOT mean the socket is always dead, from Socket.setSoTimeout ...
-
这个词是'块'。 它阻止了I / O. 它阻止。 不要对事件线程执行阻塞操作。 所有网络代码都应该在不同的线程上运行。 这包括readObject()和writeObject(),以及flush(),并创建流。 The word is 'blocks'. It's blocking I/O. It blocks. Don't perform blocking operations on the event thread. All the networking code should run on separ ...
-
通过更改来修复 while (fis.read(buffer) > 0) { outStream.write(buffer); } 至 int count; while ((count = fis.read(buffer)) > 0) { outStream.write(buffer, 0, count); } 在服务器端的ClientThread.java中 Fixed by changing while (fis.read(buffer) > 0) { outStream.w ...
-
ObjectInputStream等待传入的标头。 直到标题被完全接收,你将被困在这一行: ObjectInputStream in = new ObjectInputStream(socket.getInputStream()); 要解决此问题,您需要在建立连接后立即在另一端(即服务器)的ObjectOutputStream上调用flush() 。 有关更多信息,请阅读javadoc 。 The ObjectInputStream waits for an incoming header. Until ...
-
这可能是因为循环永远不会停止: while(true) { //code 你可以使用我为java服务器和客户端制作的类: ChatCleint package com.weebly.foxgenesis.src; import java.net.*; import java.io.*; public final class ChatClient { private Socket socket = null; private DataOutputStrea ...
-
使用Socket的PHP到Java(PHP to Java using Socket)[2023-06-12]
确定发现了问题,你必须在php中显示行结束的位置,以便套接字可以发送它,它将像魅力一样工作:) socket_write ($my_socket, $data."\r\n", strlen ($data."\r\n")); ok found the problem, you have to show where is the end of the line in php so the socket could send it, and it will work like a charm :) sock ...