2009-12-22 7 views
4
ComponentName componentName = new ComponentName("com.android.calendar", 
     "com.android.calendar.LaunchActivity"); 
if (componentName != null) { 
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW); 
    // com.android.providers.calendar.CalendarProvider 
    intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK); 

    intent.setComponent(componentName); 
    startActivity(intent); 
} else { 
    Log.i("", "98979"); 
} 

LogCat renvoie l'erreur suivante:calendrier android

ERROR/AndroidRuntime(601): Caused by: android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.android.calendar/com.android.calendar.LaunchActivity} ;
have you declared this activity in your AndroidManifest.xml?

Quelle est la nouvelle adresse de calendrier ou package?

+2

Salut, pouvez-vous éditer votre question et formater correctement l'extrait de code? Voici la référence de syntaxe Stack Overflow: http://stackoverflow.com/editing-help –

+0

Aidez-nous aussi à ce sujet http://stackoverflow.com/questions/37658179/android-calendar-show-continuous-event-that-extends -pour 2 jours ou plus –

Répondre

3

essayer,

son travail pour moi, d'ouvrir Google Agenda, pas de téléphone

Intent i = new Intent(); 

//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...) 
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity"); 

//less than Froyo 
cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity"); 

i.setComponent(cn); 
startActivity(i); 

je cherche également à ouvrir le calendrier des téléphones

1

Ceci ne fonctionne que pour les téléphones Android génériques. Sur les téléphones où le fabricant a implémenté son propre calendrier, le nom de classe des classes de calendrier sera différent.

3

essayer pour le calendrier mobile ouvert ..

int sdk = android.os.Build.VERSION.SDK_INT; 
int ICE_CREAM_BUILD_ID = android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH; 
if(sdk < ICE_CREAM_BUILD_ID) { 
    // all SDK below ice cream sandwich 
    Intent intent = new Intent(Intent.ACTION_EDIT); 
    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); 
    startActivity(intent); 
} else { 
    // ice cream sandwich and above 
    Intent intent = new Intent(Intent.ACTION_EDIT); 
    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); 

    startActivity(intent); 
} 
Questions connexes