小编xXJ*_*oXx的帖子

Android java.net.SocketException:套接字失败:EACCES(权限被拒绝)

嗨伙计们我得到了一个Android应用程序,但是当我启动它时,我的控制台出错了.我正在使用Datagram套接字创建连接,我使用2个类:( MainActivity它是应用程序的主要活动)并UdpClientServer创建连接.

这里的代码MainActivity:

public class MainActivity extends Activity {

private UdpClientServer cu;
private EditText textIpScheda;
private EditText textUdpPort;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    textIpScheda = (EditText) findViewById(R.id.textIpScheda);
    textUdpPort = (EditText) findViewById(R.id.textUdpPort);


    try {
        cu = new UdpClientServer(this);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

public EditText getTextIpScheda(){
    return textIpScheda;
}

public void setTextIpScheda(EditText textIpScheda){
    this.textIpScheda = textIpScheda;
}

public EditText getTextUdpPort() {
    return textUdpPort;
}

public void setTextUdpPort(EditText textUdpPort) {
    this.textUdpPort = textUdpPort; …
Run Code Online (Sandbox Code Playgroud)

sockets android exception

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

Android FileOutputStream位置保存文件

我有一个应用程序保存到用户输入的文件(内部存储)数据中,并在启动时加载此文件并显示内容.我想知道:我在哪里可以找到我的文件(data.txt)?另外,如果我在加载文件时输入"Hello"然后输入"World",我会在同一行看到"HelloWorld",但我希望"Hello"和"World"打印在两个不同的行上.

用于保存文件:

public void writeToFile(String data) {
    try {
        FileOutputStream fou = openFileOutput("data.txt", MODE_APPEND);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fou);
        outputStreamWriter.write(data);
        outputStreamWriter.close();
    }
    catch (IOException e) {
        Log.e("Exception", "File write failed: " + e.toString());
    }
}
Run Code Online (Sandbox Code Playgroud)

对于加载文件:

public String readFromFile() {

    String ret = "";

    try {
        InputStream inputStream = openFileInput("data.txt");

        if ( inputStream != null ) {
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String receiveString = "";
            StringBuilder stringBuilder = new StringBuilder();

            while ( …
Run Code Online (Sandbox Code Playgroud)

android save fileoutputstream

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

Android安装应用程序中的棒棒糖错误代码-505

我有一个与Android棒棒糖的nexus 9,但我得到错误代码-505试图从Play商店安装一些应用程序.

这些应用程序是:

  • 沥青8
  • 地下城猎人4
  • 六支枪; 和
  • 其他gameloft游戏

其他应用程序的工作安装正常,但这些游戏没有.

你能告诉我这个错误代码是什么意思吗?你能告诉我如何解决它吗?

installation android

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