FragmentApp.zip


android studio full src


AndroidStudio-master.zip


Toast.makeText(this,"xml연결 서버접속실패:",Toast.LENGTH_SHORT).show();

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

'앱프로그래밍 > android' 카테고리의 다른 글

android thread  (0) 2016.03.07
android 채팅  (0) 2016.03.07
android 3/3수업  (0) 2016.03.03
xml 파일읽기  (0) 2016.03.02
android  (0) 2016.02.26
by 메렁키키 2016. 3. 3. 15:57
package com.hb.adt0303;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {
TextView et;
URL url;
HttpURLConnection cn;
BufferedReader br;
InputStreamReader isr;
BufferedInputStream bis;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

et = (TextView)findViewById(R.id.etData);
et.setText("");
}//end oncreate

public void move(View v){
int id = v.getId();
if(id == R.id.btnOne){//자체데이터
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
String str = "" ;

xpp.setInput(new StringReader("<foo>spring comes soon!</foo>"));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_DOCUMENT) {
// System.out.println("Start document");
} else if (eventType == XmlPullParser.START_TAG) {
System.out.println("Start tag " + xpp.getName());
et.append("<"+xpp.getName()+">\n");
} else if (eventType == XmlPullParser.END_TAG) {
System.out.println("End tag " + xpp.getName());
et.append("</"+xpp.getName()+">");
} else if (eventType == XmlPullParser.TEXT) {
System.out.println("Text " + xpp.getText());
et.append(xpp.getText()+"\n");
}
eventType = xpp.next();
}
//System.out.println("End document");
}catch(Exception ex){

}
}else if(id == R.id.btnTwo){//톰켓서버
et.setText("");
try{

}catch(Exception ex){

}
}else if (id == R.id.btnThree){//톰켓서버xml문서
//http://203.236.209.117:8080/data/emp.xml
//et.setText("");
try {
XmlPullParserFactory factory2 = XmlPullParserFactory.newInstance();
//factory2.setNamespaceAware(true);
XmlPullParser xpp2 = factory2.newPullParser();
// et.setText("");
String path="http://203.236.209.117:8080/data/emp.xml";
url = new URL(path);
xpp2.setInput(url.openStream(), "UTF-8");
int type = xpp2.getEventType();
while(type != XmlPullParser.END_DOCUMENT){
switch (type){
case XmlPullParser.START_DOCUMENT: break;
case XmlPullParser.START_TAG:
et.append("<" + xpp2.getName() +">"); break;
case XmlPullParser.TEXT: //Thread클래스응용
et.append( xpp2.getText() ); break;
case XmlPullParser.END_TAG:
et.append("</" + xpp2.getName() +">"); break;
}//switch end
type=xpp2.next(); //RS.next( )같은역할
}//while end
}catch (Exception ex){ Log.d("hb", "xml연결 서버접속실패:" + ex.toString()); }

}else{
Toast.makeText(this,"버튼 클릭",Toast.LENGTH_SHORT).show();
et.setText("");
}
}//end move
}//end activity

'앱프로그래밍 > android' 카테고리의 다른 글

android thread  (0) 2016.03.07
android 채팅  (0) 2016.03.07
android 3/3수업  (0) 2016.03.03
fragment app 예제  (0) 2016.03.03
android  (0) 2016.02.26
by 메렁키키 2016. 3. 2. 22:04


0225목요일문서.zip

 

http://www.hanbit.co.kr/exam/4248/

=>한빛

==>t아카데미

http://www.android-town.org/


  http://webnautes.tistory.com/813(다운순서참고사이트) 

https://www.genymotion.com/#!/download 

http://developer.android.com/sdk/index.html 

http://www.oracle.com/technetwork/java/index.html


2. 사이트 

www.androidside.com 

www.androidpub.com 

www.kandroid.org1. 안드로이드 참고사이트

'앱프로그래밍 > android' 카테고리의 다른 글

android thread  (0) 2016.03.07
android 채팅  (0) 2016.03.07
android 3/3수업  (0) 2016.03.03
fragment app 예제  (0) 2016.03.03
xml 파일읽기  (0) 2016.03.02
by 메렁키키 2016. 2. 26. 00:05