Summary of andriod socket development issues

Source: Internet
Author: User

Summary of andriod socket development issues

Personal information: a senior majoring in software project of yanda University;

My blog: Google searches for "cqs_2012;

My hobbies: I love data structures and algorithms and hope to make my own contribution to algorithm work in the future;

Programming Language: Java;

Programming Environment: Windows 7 Professional Edition x64;

Programming tools: JDK, Eclipse, AVD;

Drawing tools: Office 2010 PowerPoint;

Hardware information: 7g-3 Notebook;

 

Zhenyan

Make progress only when there is a problem, and the problem makes you more logical. A problem encountered at work is a problem left over from life ---- Chen qingsong

Problem (if you have the following problem in andriod socket, check it)

1. Assume that your andriod program cannot connect to the network. Add the following statement to the list file of andriodproject.

<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. ICSS. myappnotebook"
Android: versioncode = "1"
Android: versionname = "1.0" type = "codeph" text = "/codeph">

<Uses-Permission Android: Name = "android. Permission. Internet"> </uses-Permission>
</Manifest>

2. Assume that your socket program can be connected to the serversocket of the computer in the virtual machine, but not on the mobile phone,

Pay attention to the following two points:

1). Write your clientsocket in a new thread. Do not write it in the current activity;

2) Add the following code to the oncreate () function in your current activity:

Strictmode. setthreadpolicy (New strictmode. threadpolicy. Builder (). detectdiskreads (). detectdiskwrites (). detectnetwork (). penaltylog (). Build ());
Strictmode. setvmpolicy (New strictmode. vmpolicy. Builder (). detectleakedsqlliteobjects (). penaltylog (). penaltydeath (). Build ());

Storage location, which is placed at the end of the function.

3. Assume that your socket program can connect to the serversocket of the computer in the Virtual Machine and send data to the server, but cannot receive data from the server. What should I do?

Let's stare at the close of all your socket data streams and wish you good luck.

4. If your program still has problems, please leave a message below to help you solve the problem.

Summary of andriod socket development issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.