2013-02-27 4 views
1

내 응용 프로그램에서 코드를 사용하여 장치 기본 캘린더를 열려고/programatically. 이 코드를 사용하고 있습니다 :캘린더를 볼 수 없습니다.

private void viewAllCalender() { 
     // TODO Auto-generated method stub 
     Intent i = new Intent(); 
     if(Build.VERSION.SDK_INT >= 8 && Build.VERSION.SDK_INT <= 14){ 
      i.setClassName("com.android.calendar","com.android.calendar.LaunchActivity"); 
     }else if(Build.VERSION.SDK_INT >= 15){  
      i.setClassName("com.google.android.calendar", "com.android.calendar.LaunchActivity"); 
     }else{ 
      i.setClassName("com.android.calendar","com.android.calendar.LaunchActivity"); 
     } 
     startActivity(i); 
    } 

IT가 모든 기기에서도 작동하지만 IT가 삼성 S3 작동하지 않습니다 - (SDK 버전 BUILD - 17)

나를 알아 내기 위해 제발 도와주세요 어떤 문제는 무엇입니까 ??

감사합니다.

답변

2

Android 기기에 특정 애플리케이션이있을 것으로 기대할 수는 없습니다. 심지어 재생 응용 프로그램을 설치할 것으로 예상 될 수 있습니다. 이 작업을 수행하는 올바른 방법은 .setClassName을 사용하지 않고 사용자가 수행 할 작업을 결정하도록하는 것입니다. 당신이를 처리하는 내 CalendarOrganizer를 사용할 수있는 달력에 이벤트를 추가하려면

...

편집

이 12 개의 캘린더 응용 프로그램이며, 전화는 각각 자신이 제조 이러한 문제의 많은 :

public class CalendarOrganizer { 
    private final static int ICE_CREAM_BUILD_ID = 14; 
    /** 
    * Creates a calendar intent going from startTime to endTime 
    * @param startTime 
    * @param endTime 
    * @param context 
    * @return true if the intent can be handled and was started, 
    * false if the intent can't be handled 
    */ 
    public static boolean createEvent(long startTime, long endTime, String title, String description, 
      String location, boolean isAllDay, Context context) { 
     Intent intent = new Intent(Intent.ACTION_EDIT); 
     int sdk = android.os.Build.VERSION.SDK_INT; 
     if(sdk < ICE_CREAM_BUILD_ID) { 
      // all SDK below ice cream sandwich 
      intent.setType("vnd.android.cursor.item/event"); 
      intent.putExtra("beginTime", startTime); 
      intent.putExtra("endTime", endTime); 
      intent.putExtra("title", title); 
      intent.putExtra("description", description); 
      intent.putExtra("eventLocation", location); 
      intent.putExtra("allDay", isAllDay); 

//   intent.putExtra("rrule", "FREQ=YEARLY"); 
     } else { 
      // ice cream sandwich and above 
      intent.setType("vnd.android.cursor.item/event"); 
      intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); 
      intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); 
      intent.putExtra(Events.TITLE, title); 
      intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); 
      intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY , isAllDay); 
      intent.putExtra(Events.DESCRIPTION, description); 
      intent.putExtra(Events.EVENT_LOCATION, location); 

//   intent.putExtra(Events.RRULE, "FREQ=DAILY;COUNT=10") 
     } 
     try { 
      context.startActivity(intent); 
      return true; 
     } catch(Exception e) { 
      return false; 
     } 
    } 
} 
+0

답장을 보내 주셔서 감사합니다. 삼성 S3에서이 문제를 어떻게 해결할 수 있습니까? –

+0

@ BorntoWin 캘린더에 일정을 추가하는 방법을 보여주는 예가 추가되었지만 찾고있는 것이 맞다면 분명하지 않습니다. 달력 응용 프로그램을 열려면 운이 좋지 않습니다. 당신은 저처럼 할 수 있고 그 주위에 try catch 블록을 넣어 앱이 전화가 없을 때마다 사용자에게 알려줍니다. – Warpzit