How to create an extension for the Etar Calender in Android Studio? I want that the created event from me to be sent on WhatsApp or Messenger.
CodePudding user response:
- You can try these In Android Studio, create a new project and select the "Empty Activity" template.
- Call the activity "EtarCalendarActivity".
- In the AndroidManifest.xml file, add the following permissions:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.CAMERA"/>
- Also add the following line to the manifest file:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name">
- In the EtarCalendarActivity.java file, import the following classes:
import android.app.Activity; import android.os.Bundle; import android.widget.Toast; import com.etar.calendar.EtarCalendar; import com.etar.calendar.EtarDatePicker; import com.etar.calendar.EtarTimePicker;
- Add the following code to the EtarCalendarActivity class:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_etar_calendar); EtarCalendar etarCalendar = (EtarCalendar) findViewById(R.id.etarCalendar); EtarDatePicker etarDatePicker = (EtarDatePicker) findViewById(R.id.etarDatePicker); EtarTimePicker etarTimePicker = (EtarTimePicker) findViewById(R.id.etarTimePicker); etarCalendar.setListener(new EtarCalendar.Listener() { @Override public void onDateSelected(EtarDatePicker etarDatePicker, EtarDate etarDate) { Toast.makeText( EtarCalendarActivity.this, etarDate.toString(), Toast.LENGTH_SHORT).show(); } @Override public void onTimeSelected( EtarTimePicker etarTimePicker, EtarTime etarTime) { Toast.makeText( EtarCalendarActivity.this, etarTime.toString(), Toast.LENGTH_SHORT).show(); } }); etarDatePicker.setListener(new EtarDatePicker.Listener() { @Override public void onDateSelected( EtarDatePicker etarDatePicker, EtarDate etarDate) { EtarTimePicker etarTimePicker = (EtarTimePicker) findViewById(R.id.etarTimePicker); etarDate.set(etarDatePicker.getDate()); etarTime.set(etarTimePicker.getTime()); } }); etarTimePicker.setListener(new EtarTimePicker.Listener() { @Override public void onTimeSelected( EtarTimePicker etarTimePicker, EtarTime etarTime) { EtarDatePicker etarDatePicker = (EtarDatePicker) findViewById(R.id.etarDatePicker); etarDate.set(etarDatePicker.getDate()); } }); }
- Run the application.