¾ÛÅøÁî
46.¢½.168.138
46.¢½.168.129
46.¢½.168.161
46.¢½.168.136
46.¢½.168.145
46.¢½.168.162
46.¢½.168.144
46.¢½.168.140
115.¢½.135.198
46.¢½.168.139
 
°Ô½Ã¹° 88°Ç
   
¿øº»ÀÌ ¼öÁ¤ÀÌ ¾ÈµÇ´Â°ü°è·Î...(±¸±Û Ķ¸°´õ ¸®½ºÆ®JSON±Ü¾î¿À±â+ µî·Ï)
±Û¾´ÀÌ : ±èº´ÁÖ                   ³¯Â¥ : 2011-12-03 (Åä) 04:21 Á¶È¸ : 6682
1. ¿ì¼± Á¶»çÇغ»°á°ú ÀÌÀü¿¡ ¾Ë·Áµå¸°¹æ¹ýÀº. GDATA´Â ¾²±â,»èÁ¦ µîÀÇ À̺¥Æ®¸¸ »ç¿ë°¡´ÉÇϽʴϴÙ.
 
2. GDATA·Î´Â ¸®½ºÆ®¸¦ ½ºÄµºÒ°¡´ÉÇÕ´Ï´Ù. ¶ÇÇÑ ¾²±â »èÁ¦ µîÀÌ °¡´ÉÇÏ´Ù°í Çصµ ResponeÀ̳ª RequestÄڵ带 ¹ÞÀ» ¼ö ¾ø½À´Ï´Ù. (ÆÄ½Ì ¿ö´× ³ª¿É´Ï´Ù.)
 
3. µû¶ó¼­ À§ÀÇ ¸®½ºÆ® ½ºÄµ¹æ¹ý°ú + ¾Æ·¡ÀÇ GDATA ±Û µî·Ï¹æ½ÄÀ» ÇÕÄ£¹æ¹ýÀ» ³Ö¾îµ×½À´Ï´Ù.
 
À§ÀÇ ¼Ò½º¿Í ³»¿ëÀÌ ÀüüÀûÀ¸·Î ºñ½ÁÇϹǷÎ, µû·Î ÁÖ¼®À» ´ÞÁø ¾Ê°Ù½À´Ï´Ù.
<¼Ò½º>
package com.corea.Gdata;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.DateTime;
import com.google.gdata.data.Person;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.calendar.CalendarEventEntry;
import com.google.gdata.data.calendar.CalendarEventFeed;
import com.google.gdata.data.extensions.When;
import com.google.gdata.data.extensions.Where;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ContentType;
import com.google.gdata.util.ServiceException;
public class Google_Gdata_Test extends Activity {
    /** Called when the activity is first created. */
 static String USER_ID;
 static String USER_Pass;
 static String APP_NAME;
 TextView text;
 static ArrayList<String> items;
 static ArrayList<String> items2;
 static ArrayList<String> items3;
 JSONArray arr;
 String ar;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
 
        USER_ID = "Áö¸ÞÀÏ °èÁ¤";
        USER_Pass = "ºñ¹Ð¹øÈ£";
        APP_NAME = "¾ÛÀ̸§";
        items = new ArrayList<String>();
        items2 = new ArrayList<String>();
        items3 = new ArrayList<String>();
        text = new TextView(this);
        text = (TextView)findViewById(R.id.text);
     
      authdata();
      if(ar!=null)
      {
       getList();
      
      }
      if(arr.length()!=0)
      {
       for(int i=0; i<arr.length(); i++)
       {
       try {
    text.append("\n"+arr.getString(i)+"\n");
   } catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
       }
      }
      else{}
 
    }
   public void getList()
   {
  try {
     items3=new ArrayList<String>();
     URL url = new URL("http://www.google.com/calendar/feeds/"+USER_ID+"/private/full?alt=json");
     HttpURLConnection con = (HttpURLConnection)url.openConnection();
     con.setDoOutput(true);
     con.setRequestMethod("GET");
     con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
     con.setRequestProperty("Authorization", "GoogleLogin auth="+ar);
     InputStream un = con.getInputStream();
     BufferedReader br = new BufferedReader(new InputStreamReader(un));
     String ud;
     arr = new JSONArray();
     while((ud=br.readLine())!=null)
     {
      arr.put(ud);
     }
     br.close();
  }
  catch (MalformedURLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
}  
   }
   
   public void authdata()
   {
      items = new ArrayList<String>();
      
       URL url;
    try {
     url = new URL("https://www.google.com/accounts/ClientLogin ");
    
       HttpURLConnection con = (HttpURLConnection)url.openConnection();
       con.setDoOutput(true);
       con.setRequestMethod("POST");
       OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
       out.write(
         "&Email="+USER_ID
        // +"&postId="+"1"
         //+"&commentId="+"9155368"
         +"&Passwd="+USER_Pass
         +"&source="+APP_NAME
         +"&service="+"cl");
       out.flush();
       InputStream put = con.getInputStream();
       out.close();
       BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
       String decodedString;
       while((decodedString = in.readLine())!=null)
       {
       items.add(decodedString);
       }
       in.close();
       ar = items.get(2).substring(5);
       System.out.println(ar);
    } catch (MalformedURLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }  
   }

    public void AddEventSce(String Title, String Note, Date Startdate, Date EndDate, String Location)
    {
    Toast.makeText(getBaseContext(), "login..", Toast.LENGTH_SHORT).show();
    try {
  URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/private/full?alt=json");
  
  CalendarEventEntry myEntry = new CalendarEventEntry();
  
  myEntry.setTitle(new PlainTextConstruct("Test_App","utf-8"));
  myEntry.setContent(new PlainTextConstruct("¾È³çÇϼ¼¿ä","utf-8"));
  Person author = new Person("Test_app",null,USER_ID);
  myEntry.getAuthors().add(author);
  DateTime startTime = new DateTime(new Date(2011-1900,12-1,3,12,0));
  startTime.setTzShift(9);
  DateTime endTime = new DateTime(new Date(2011-1900,12-1,3,13,0));
  endTime.setTzShift(9);
  When eventTimes = new When();
  eventTimes.setStartTime(startTime);
  eventTimes.setEndTime(endTime);
  myEntry.addTime(eventTimes);
  Where evLocaiton = new Where();
  evLocaiton.setValueString("¼­¿ï");
  myEntry.addLocation(evLocaiton); 
  CalendarService myService = new CalendarService("Test_App");
  myService.setUserCredentials(USER_ID,USER_Pass);
  ContentType ct = new ContentType();
//  ct.setType("application/json;charset=utf-8");
//  myService.setContentType(ct);
  myService.insert(feedUrl, myEntry);

 } catch (AuthenticationException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (MalformedURLException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (ServiceException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
     
     
    }
}
 
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)




±èº´ÁÖ ´ÔÀÇ Tip&Tech ÃÖ½Å±Û [´õº¸±â]


   

°Ô½Ã¹° 88°Ç
¹øÈ£ Á¦¸ñ ±Û¾´ÀÌ ³¯Â¥ Á¶È¸
88  The content of the adapter has changed but ListView ... ¿¡·¯ ÀϹÝÀû ÇØ°á¹ý. ±èº´ÁÖ 04-16 15329
87  ZXing ¹ÙÄÚµå ½ºÄµºÎºÐ Å©±â Á¶ÀýÇϱâ. ±èº´ÁÖ 08-06 14603
86  ¾Èµå·ÎÀ̵å Çػ󵵺° ÁÂÇ¥+ À̹ÌÁö Å©±â ¼öÁ¤Çϱâ(º¯Á¾µð½ºÇ÷¹ÀÌ´Â Àû¿ëx) ±èº´ÁÖ 01-18 13143
85  ÁÖ¼Ò·Ï Ãß°¡/»èÁ¦ °¨ÁöÇؼ­ ¾ÛÀÇ dbÃß°¡/»èÁ¦Çϱâ. ±èº´ÁÖ 09-24 12416
84  ¾ÛÅÛÇø´À» Á¦°øÇÏ´Â »çÀÌÆ® ¼Ò°³ÇÕ´Ï´Ù. ¾¾Æ®¸°°³¹ß¡¦ 08-21 12205
83  °£¸¸¿¡ ±Û¾²³×¿ä À̹ø¿£ launcherShortCut (¹Ù·Î°¡±â ¾ÆÀÌÄÜ)ÀÔ´Ï´Ù. ±èº´ÁÖ 07-25 11970
82     [Agate Mobile] ¾Û ¼³Ä¡ ¾øÀÌ ¼­¹ö·ÎºÎÅÍ ½Ç½Ã°£ ·Îµù µÇ¾î µ¿ÀÛÇÏ´Â Cloud Native App ÇÁ·¹ÀÓ¿öÅ©ÀÔ´Ï´Ù. ±èÀºÈ£ 08-21 11957
81  [ÆÁ] °¶·°½Ã ³ëÆ®3 °³¹ßÀÚ ¿É¼Ç ¸Þ´º ã±â ^^ ÀÌ°æ¿ë 11-09 9615
80  JRE ½Ã½ºÅÛ ¶óÀ̹ö·¯¸® °ü·Ã ¿À·ù ó¸® +1 ÀÌ°æ¿ë 12-11 9306
79  À½·Â->¾ç·Â , ¾ç·Â ->À½·Â ¾Ë°í¸®Áò. ±èº´ÁÖ 10-14 9131
78  arraylist Áߺ¹µ¥ÀÌÅÍ Á¦°Å +4 ÀÌ°æ¿ë 10-05 9095
77  ³¯¾¾¾Û Á¦ÀÛÇϽô ºÐµé Âü°í¿ë. +1 ±èº´ÁÖ 01-06 8482
76  handler¸¦ ÀÌ¿ëÇØ °¡º¯½Ã°£ ¹Ýº¹ ÀÛ¾÷Çϱâ. ±èº´ÁÖ 11-26 8328
75  °£´ÜÇÑ À§Á¬ ¸¸µé±â. +1 ±èº´ÁÖ 11-21 8010
74  È®À帮½ºÆ®°¡ 3µª½º ÀÌ»óÀÌ µÉ±î? ¾ÈµÉ±î? +1 ±èº´ÁÖ 08-21 7571
73  [Agate Mobile] ¾Û ¼³Ä¡ ¾øÀÌ ¼­¹ö·ÎºÎÅÍ ½Ç½Ã°£ ·Îµù µÇ¾î µ¿ÀÛÇÏ´Â Cloud Native App ÇÁ·¹ÀÓ¿öÅ©ÀÔ´Ï´Ù. ¾¾Æ®¸°°³¹ß¡¦ 07-21 7394
72  À̹ø¿¡ °³¹ßÇÑ ¼îÇθô¾Û Àüü ¼Ò½ºÀÔ´Ï´Ù. +7 ¾¾Æ®¸°°³¹ß¡¦ 04-26 7162
71  ±¸±Û Ä̸°´õ ¿¬µ¿Çϱâ. +6 ±èº´ÁÖ 11-30 7130
70  ¸®½ºÆ® ÀÛ¾÷½Ã¿¡ ±âº»ÀûÀ¸·Î ¾Ë¾ÆµÎ¼Å¾ß µÉÁ¡. +1 ±èº´ÁÖ 10-08 6795
69  LazyList¸¦ ¼Ò°³ÇÕ´Ï´Ù. ÀÌ¿øÈñ 02-07 6740
 1  2  3  4  5  
 
 
 
Copyright ¨Ï wwwold.androidstudy.co.kr. All rights reserved.