Android World
Sunday, 7 April 2013
Add reminders in all events in Android calendar
This example adds a reminder to an event. The reminder fires 10 minutes before the event.
And add an event and a reminder this way:
// get calendar
Calendar cal = Calendar.getInstance();Uri EVENTS_URI = Uri.parse(getCalendarUriBase(this) + "events");ContentResolver cr = getContentResolver();// event insertContentValues values = new ContentValues();values.put("calendar_id", 1);values.put("title", "Reminder Title");values.put("allDay", 0);values.put("dtstart", cal.getTimeInMillis() + 11*60*1000); // event starts at 11 minutes from nowvalues.put("dtend", cal.getTimeInMillis()+60*60*1000); // ends 60 minutes from nowvalues.put("description", "Reminder description");values.put("visibility", 0);values.put("hasAlarm", 1);Uri event = cr.insert(EVENTS_URI, values);// reminder insertUri REMINDERS_URI = Uri.parse(getCalendarUriBase(this) + "reminders");values = new ContentValues();values.put( "event_id", Long.parseLong(event.getLastPathSegment()));values.put( "method", 1 );values.put( "minutes", 10 );cr.insert( REMINDERS_URI, values );
You'll also need to add these permission to your manifest for this method:
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
How to get contact list from Exchange Server in Android?
How to obtain the contacts from
global address list(GAL)
of Microsoft Office 365
.
or How do I retrieve
global contacts
with Exchange Web Services (EWS)
?
Android Application that looks up
Exchange GAL
for contacts
Also u can refer
Use a string literal that contains an embedded single-quote (') character in Android
The SQL standard specifies that single-quotes in strings are escaped by putting two single quotes in a row.
Example:
INSERT INTO xyz VALUES('5 O''clock');
So use '' at the place of '. like
if(constraint.contains("'")) constraint = constraint.replace("'", "''");
ContactsContract.Contacts.DISPLAY_NAME + " LIKE '"+constraint+"%'"
Get AndroidManifest.xml Content in code
Inside
theonCreate()
method use
try
{
String app_ver = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
}
catch (NameNotFoundException e)
{
Log.v(tag, e.getMessage());
}
Friday, 10 February 2012
DatePickerDialog & TimePickerDialog in Android
DatePickerDialog is not a View, that you can’t define it in the xml layout file.
Instead you declare it from code with the following two constructors:
Instead you declare it from code with the following two constructors:
DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth); DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth);
You can use it like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.btn);
final OnDateSetListener odsl=new OnDateSetListener()
{
public void onDateSet(DatePicker arg0, int year, int month, int dayOfMonth) {
// TODO Auto-generated method stub
TextView txt=(TextView)findViewById(R.id.txt);
txt.setText("The date is "+dayOfMonth+"/"+month+"/"+year);
}
};
btn.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0) {
// TODO Auto-generated method stub
Calendar cal=Calendar.getInstance();
DatePickerDialog datePickDiag=new DatePickerDialog(DateTimeControls.this,odsl,cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH));
datePickDiag.show();
}
}
);
}
To take an action when the date is set you define an OnDateSelectedListner and implement the onDateSet method
TimePickerDialog
DatePickerDialog is similar to DatePickerDialog but used for setting time.
The constructors for TimePickerDialog are:
TimePickerDialog(Context context, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView); TimePickerDialog(Context context, int theme, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView);
Code :
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn=(Button)findViewById(R.id.btn); } final OnTimeSetListener otsl=new OnTimeSetListener() { public void onTimeSet(TimePicker arg0, int hourOfDay, int minute) { // TODO Auto-generated method stub TextView txt=(TextView)findViewById(R.id.txt); txt.setText("The time is "+hourOfDay+":"+minute); } }; btn.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub Calendar cal=Calendar.getInstance(); TimePickerDialog timePickDiag=new TimePickerDialog(DateTimeControls.this,otsl,cal.get(Calendar.HOUR_OF_DAY),cal.get(Calendar.MINUTE),true); timePickDiag.show(); } } );
Google TV
Google TV is built on Android and Chrome platforms that provide a scalable way to bring your apps to TV.
https://developers.google.com/tv/
https://developers.google.com/tv/
Subscribe to:
Posts (Atom)