android - Starting two intents one after another -
I am trying to start two calendar entries that are clicked after a button, but this is not work Has been doing.
Code:
Intent calIntent1 = new intent (int. Action_INSERT); CalIntent1.setType ("vnd.android.cursor.item / event"); CalIntent1.putExtra (Events.TITLE, "TITLE"); Gregorian calendar calDate1 = New Gregorian calendar (year, month, day, hour, minute); CalIntent1.putExtra (Calendar contact. EXTRA_EVENT_ALL_DAY, incorrect); CalIntent1.putExtra (Calendar contact. EXTRA_EVENT_BEGIN_TIME, calDate1.getTimeInMillis ()); CalIntent1.putExtra (Calendar Contract. EXTRA_EVENT_END_TIME, calDate1.getTimeInMillis () + 2 * 60 * 60 * 1000); Intent calientent 2 = new intent (Intent.ACTION_INSERT); CalIntent2.setType ("vnd.android.cursor.item / event"); CalIntent2.putExtra (Events.TITLE, "TITLE2"); Gregorian calendar calDate2 = New Gregorian calendar (year, month, day, hour, minute); CalIntent2.putExtra (calendar contract. EXTRA_EVENT_ALL_DAY, incorrect); CalIntent2.putExtra (Calendar contact. EXTRA_EVENT_BEGIN_TIME, calDate2.getTimeInMillis ()); CalIntent2.putExtra (calendar contract.EXTRA_EVENT_END_TIME, calDate2.getTimeInMillis () + 2 * 60 * 60 * 1000); StartActivity (calIntent2); StartActivity (calIntent1);
Why is not any idea working?
Thank you in advance
You can call onActivityResult method You can start 1 intent and wait for its result. And then you can start your second intention. Some example codes for you:
package ** yourpackagename **; Import java.util.GregorianCalendar; Import android App Import android.content.Intent; Importroid.os.Bundle; Import Android. Provider. Calendar cantrecht; Import android.provider.CalendarContract.Events; Public class doubent class class activity extends {public static final interval REQUEST_FIRST_INTENT = 10; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); // Call your method here (2014, 9, 10, 5, 20); } Public Zero yourMethodName (int year, int month, int day, int hr, int min) {intent calentant 1 = new intent (intent. Acronym SCRT); CalIntent1.setType ("vnd.android.cursor.item / event"); CalIntent1.putExtra (Events.TITLE, "TITLE"); Gregorian calendar calDate1 = New Gregorian calendar (year, month, day, hour, minute); CalIntent1.putExtra (Calendar contact. EXTRA_EVENT_ALL_DAY, incorrect); CalIntent1.putExtra (Calendar contact. EXTRA_EVENT_BEGIN_TIME, calDate1.getTimeInMillis ()); CalIntent1.putExtra (Calendar Contract. EXTRA_EVENT_END_TIME, calDate1.getTimeInMillis () + 2 * 60 * 60 * 1000); StartActivityForResult (calIntent1, REQUEST_FIRST_INTENT); } @ Override Protective Result on Intact Result (Int RequestCode, Int Results Results, Intent Data) {super.onActivityResult (requestCode, resultCode, Data); // If this is true, then it means that your first intention is over. You can start your second intention if (requestcode == REQUEST_FIRST_INTENT) {intent calIntent2 = new intent (Intent.ACTION_INSERT); CalIntent2.setType ("vnd.android.cursor.item / event"); CalIntent2.putExtra (Events.TITLE, "TITLE2"); Gregorian calendar calDate2 = New Gregorian calendar (year, month, day, hour, minute); CalIntent2.putExtra (calendar contract. EXTRA_EVENT_ALL_DAY, incorrect); CalIntent2.putExtra (Calendar contact. EXTRA_EVENT_BEGIN_TIME, calDate2.getTimeInMillis ()); CalIntent2.putExtra (calendar contract.EXTRA_EVENT_END_TIME, calDate2.getTimeInMillis () + 2 * 60 * 60 * 1000); StartActivity (calIntent2); }}}
Comments
Post a Comment