2011-03-06 4 views
1

gdata를 사용하여 Google 캘린더에 액세스하려고합니다. 그러나 응용 프로그램이 종료 :( 나는 외부 항아리로 GDATA 클라이언트-1.0.jar 추가 한 여기 android google calendar .. 응용 프로그램 닫기 close

내 파일입니다 rrr.java 패키지 caleda.qwe,

import java.net.URL; 

import com.google.gdata.client.calendar.CalendarService; 
import com.google.gdata.data.calendar.CalendarEntry; 
import com.google.gdata.data.calendar.CalendarFeed; 

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 

public class rrr extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     String res="not proper"; 
    // Create a CalenderService and authenticate 
     CalendarService myService = new CalendarService("calendar"); 
     try{ 
     myService.setUserCredentials("sunnycool333", "XXXXX"); 

     // Send the request and print the response 
     URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/owncalendars/full"); 
     CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class); 
     // System.out.println("Calendars you own:"); 
     // System.out.println(); 
     for (int i = 0; i < resultFeed.getEntries().size(); i++) { 
      CalendarEntry entry = resultFeed.getEntries().get(i); 
     // System.out.println("\t" + entry.getTitle().getPlainText()); 
      res=entry.getTitle().getPlainText(); 
     } 
     } 
     catch (Exception e) { 
      // TODO: handle exception 
      //System.out.println("not working"); 
      res=e.toString(); 
     } 

     TextView view = (TextView)findViewById(R.id.TextView01); 
     view.setText(res); 
    } 
} 

main.xml에.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" 
    /> 
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
</LinearLayout> 

applicationmanifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="caleda.qwe" 
     android:versionCode="1" 
     android:versionName="1.0"> 
     <uses-permission android:name="android.permission.INTERNET" /> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".rrr" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 


</manifest> 

누군가 내 실수를 지적 할 수있게 도와 줄 수 있습니까?

+0

Logcat에 어떤 오류가 표시됩니까? –

+0

오류 로그를 붙여 넣지 않은 이유는 무엇입니까? 그 안에 실제 오류가 있고 뭔가 (nullpointerexception 같은)가 일어나는 곳을 가리 킵니다. – Nanne

답변

1

UI 스레드에서 네트워크 액세스를 사용 중이므로 Application Not Responding 대화 상자로 인해 작업이 실패 할 수 있습니다.

AsyncTask을 사용해보세요.

This question에는 AsyncTask와 관련된 몇 가지 예제 코드 및 링크가 있습니다.

외부 항아리가 해결됩니다 문제를 파일로 우리는 두 개의 파일을 추가하면

..

두 개의 파일을 GDATA 클라이언트 SRC의 "deps"폴더에 있습니다

+0

03-06 16 : 27 : 40.259 : 오류/dalvikvm (3252) : 스택 추적 파일 '/data/anr/traces.txt'을 열 수 없음 : 사용 권한이 거부되었습니다. 03-06 16 : 30 : 04.759 : ERROR/AndroidRuntime 3336) : 오류 : 스레드 연결이 실패했습니다. 03-06 16 : 30 : 06.910 : ERROR/AndroidRuntime (3329) : 오류 : 스레드 연결이 실패했습니다. 03-06 16 : 30 : 06.910 : ERROR/AndroidRuntime (3335) : 알려지지 않은 핸들러 : 잡히지 않은 예외로 인한 스레드 메인 ..... 03-06 16 : 30 : 06.910 : ERROR/AndroidRuntime (3335) : ... 14 more 03-06 16:30 : 06.910 : 오류/dalvikvm (3335) : 스택 추적 파일 '/data/anr/traces.txt'을 열 수 없습니다 : 사용 권한이 거부되었습니다. –

0

고마워요 모두 ... .. named : google-collect-1.0-rc1.jar & jsr305.jar

관련 문제