In my application I need to add contact info from my app into phonebook of BlackBerry.
How can I achieve it?
I have referred to the Java development guide "Create a contact and assign it to a contact list"
Check out the Contact documentation for more information
Create a contact and everytime you have to check out that if it supports the Field
ContactList contacts = null;
try {
contacts = (ContactList) PIM.getInstance().openPIMList( PIM.CONTACT_LIST,
PIM.READ_WRITE );
} catch( PIMException e ) {
// An error occurred
return;
}
Contact contact = contacts.createContact();
String[] name = new String[ contacts.stringArraySize( Contact.NAME ) ];
name[ Contact.NAME_GIVEN ] = "John";
name[ Contact.NAME_FAMILY ] = "Public";
String[] addr = new String[ contacts.stringArraySize( Contact.ADDR ) ];
addr[ Contact.ADDR_COUNTRY ] = "USA";
addr[ Contact.ADDR_LOCALITY ] = "Coolsville";
addr[ Contact.ADDR_POSTALCODE ] = "91921-1234";
addr[ Contact.ADDR_STREET ] = "123 Main Street";
try {
contact.addString( Contact.NAME_FORMATTED, PIMItem.ATTR_NONE,
"Mr. John Q. Public, Esq." );
contact.addStringArray( Contact.NAME, PIMItem.ATTR_NONE, name );
contact.addStringArray( Contact.ADDR, Contact.ATTR_HOME, addr );
contact.addString( Contact.TEL, Contact.ATTR_HOME, "613-123-4567" );
contact.addToCategory( "Friends" );
contact.addDate( Contact.BIRTHDAY, PIMItem.ATTR_NONE, new Date().getTime() );
contact.addString( Contact.EMAIL, Contact.ATTR_HOME
| Contact.ATTR_PREFERRED, "jqpublic#xyz.dom1.com" );
} catch( UnsupportedFieldException e ) {
// In this case, we choose not to save the contact at all if any of the
// fields are not supported on this platform.
System.out.println( "Contact not saved" );
return;
}
try {
contact.commit();
} catch( PIMException e ) {
// An error occured
}
try {
contacts.close();
} catch( PIMException e ) {
}
Related
I have this addaction controller and i'm getting this exception error though user are getting added.
public function addAction() {
$requestObj = $this->getRequest();
$viewModelObj = new ViewModel();
$errorMsg = array();
$userObj = new Entity\User();
try {
$userRepo = $this->getDoctrineRepository('User');
if ($this->getRequest()->getQuery('id')) {
$userObj = $userRepo->findOneBy(array('id'=>$this->getRequest()->getQuery('id')));
}
if ($requestObj->isPost()) {
$postData = $requestObj->getPost()->getArrayCopy();
$currentUser = $this->getFromSession('user');
$error = false;
if (trim($requestObj->getPost('firstName')) == "") {
$errorMsg[] = "First name is required";
$error = true;
}
if ($this->getRequest()->getQuery('id')) {
if($userObj->getCellPhone() != $postData['cellPhone']) {
if($userRepo->findOneBy(array('cellPhone'=> $postData['cellPhone']))) {
$errorMsg[] = "Cell Phone is already exists.";
$error = true;
}
}
} else {
$existUserByEmailObj = $userRepo->findOneBy(array('email'=> $postData['email']));
$existUserByCellObj = $userRepo->findOneBy(array('cellPhone'=> $postData['cellPhone']));
if($existUserByEmailObj){
$errorMsg[] = "Email is already exists.";
$error = true;
}
if($existUserByCellObj){
$errorMsg[] = "Cell Phone is already exists.";
$error = true;
}
}
if ($userObj->getId() && trim($requestObj->getPost('password')) == "") {
$postData['password'] = $userObj->getPassword();
} else if (trim($requestObj->getPost('password')) == "") {
// user add
$errorMsg[] = "Password is required";
$error = true;
}
// in edit if password is empty then insert previous password
// populate object with form data
$hydratorObj = new Hydrator\ClassMethods();
$hydratorObj->hydrate($postData, $userObj);
if($error == false) {
$userObj->setUpdatedBy($currentUser->getId());
$eMObj = $this->getDoctrineEntityManager();
if ($userObj->getId()) {
//$userObj->setIsVerified(2);
$eMObj->merge($userObj);
} else {
$userObj->setCreatedDate(new \DateTime("now"));
$userObj->setCreatedBy($currentUser->getId());
//$userObj->setIsVerified(2);
$eMObj->persist($userObj);
}
$eMObj->flush();
// Set User Sms Number
$userSmsNumberRepo = $this->getDoctrineRepository('UserSmsNumber');
$userSmsNumberObj = $userSmsNumberRepo->findOneBy(array('user'=> $userObj->getId()));
if(!$userSmsNumberObj) {
$smsNumberRepo = $this->getDoctrineRepository('SmsNumber');
$smsNumberObj = $smsNumberRepo->findSmsNumber();
if ($smsNumberObj) {
$userSmsNumberObj = new Entity\UserSmsNumber();
$userSmsNumberObj->setUser($userObj);
$userSmsNumberObj->setSmsNumber($smsNumberObj);
$smsNumberObj->setNoOfAssignee((int)$smsNumberObj->getNoOfAssignee() + 1);
}
$eMObj->persist($userSmsNumberObj);
$eMObj->merge($smsNumberObj);
$eMObj->flush();
// Send Email Alert to Admin if last one SmsNumber is exists.
$lastSmsNumber = $smsNumberRepo->lastOneSmsNumber();
if($lastSmsNumber == 0 || $lastSmsNumber == 1) {
$settingObj = $this->getDoctrineRepository('Setting');
$adminEmail = $settingObj->findValueByFieldName('ADMIN_EMAIL');
$sendArr = array($adminEmail => 'Fence-alert');
$placeholderArr = array('NAME' => 'Admin', 'SMSNUMBER' => $smsNumberObj->getSmsNumber(), 'NOOFASSIGNEE' => (int)$smsNumberObj->getNoOfAssignee());
$sendMailObj = new SendEmail($this->serviceLocator);
$sendMailObj->send($sendArr, 'SMSNUMBER_ALERT', $placeholderArr, $toAdmin = TRUE);
}
}
$this->flashMessenger()->addMessage('User Saved Successfully!');
$this->redirect()->toUrl(BASE_URL.'/admin/user');
}
}
$form = new UserForm($this->getServiceLocator(), 'formUser');
$form->bind($userObj);
$form->get('password')->setAttribute('type', 'text');
$form->get('password')->setValue($userObj->getPassword());
$viewModelObj->setVariables(array(
'errorMsg' => $errorMsg,
'form' => $form,
'userObj' => $userObj
));
return $viewModelObj;
} catch(\Exception $e) {
print_r($e);
$this->flashMessenger()->addMessage('Exception Error: User not saved.');
return $this->redirect()->toUrl(BASE_URL.'/admin/user');
}
}
error:
Doctrine\ORM\ORMInvalidArgumentException Object ( [message:protected] => EntityManager#persist() expects parameter 1 to be an entity object, NULL given.
...............................................................................................................................................................................................................................................................................................
I checked the code and I think the problem could be this:
At the row number 82 you check if $userSmsNumberObj is an object.
If it's null you enter in the if statement
At row number 85 you check if $smsNumberObj is an object or null
In case $smsNumberObj is null you jump to row 92 without instantiate a new UserSmsNumber and you try to persist a null value
I think you have to check if $userSmsNumberObj is an object before try to persist at row 92.
I have an Asp MVc web project. In order to sell product, the user should register or login to my website. After choosing its product, the user will redirect to bank gateway through PaymentAction method:
public String PaymentAction( TransAction Model )
{
try
{
Payment ob = new Payment();
Model.amount = 100000.ToString();
string result = ob.pay(Model.amount);
//, User.Identity.GetUserId()
/*
the result var is a string that contains the response from pay.ir/send
which contains: status, transId, errorCode, errorMessage and all things that
exist in JsonParameter
*/
JsonParameters Parmeters = JsonConvert.DeserializeObject<JsonParameters>(result);
// in this point the payment was successful and you can add info to your database
if ( Parmeters.status == 1 )
{
Response.Redirect("https://pay.ir/payment/gateway/" + Parmeters.transId);
}
else
{
return "error code : " + Parmeters.errorCode + "<br />" + "message " + Parmeters.errorMessage;
}
return "";
}
catch ( Exception exp )
{
return "error" + exp.Message;
}
}
after payment, the user redirect to my website through the following url:
http://www.mymvcapp.com/HelpMeToBuildMyExtraordinaryYear/VerifyPayment
and here is the VerifyPayment method:
[HttpPost]
[AllowAnonymous]
public ActionResult VerifyPayment( VerifyResult Vresult )
{
try
{
if ( !string.IsNullOrEmpty(Request.Form["transId"]) )
{
Payment ob = new Payment();
string result = ob.verify(Request.Form["transId"].ToString());
JsonParameters Parmeters = JsonConvert.DeserializeObject<JsonParameters>(result);
if ( Parmeters.status == 1 )
{
var userId = User.Identity.GetUserId();
var user = db.Users.Where(u => u.Id == userId).FirstOrDefault();
user.SuccessfullPayment = true;
user.FactorNo = User.Identity.GetUserId();
user.TraceNo = Request.Form["traceNumber"];
user.TransId = int.Parse(Request.Form["transId"]);
user.CardNo = Request.Form["cardNumber"];
user.PurchasedDate = DateTime.Now;
user.State = Parmeters.status;
user.Message = Request.Form["message"];
db.Entry(user).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
Vresult.success = true;
Vresult.TransActionID += Request.Form["transId"].ToString();
Vresult.Amount += Parmeters.amount.ToString();
Vresult.SuccessMessage = "successful payment";
return RedirectToAction("Index", "DownloadEbook", new { traceNumber = user.TraceNo , factorNumber = user.FactorNo, purchaseDate =Utils.Funcs.ObtainPersianDate( (DateTime)user.PurchasedDate ) });
}
else
{
Vresult.error = true;
Vresult.ErrorMessage = "error code " + Parmeters.errorCode + "<br />" + "Errr meesafe " + Parmeters.errorMessage;
}
}
}
catch ( Exception ex )
{
Vresult.error = true;
Vresult.ErrorMessage = ex.Source+"\t"+ex.InnerException + "\t" + ex.Message+"ERRR";
}
return View(new AllNeededModels() { VerifyResult = Vresult });
as we can see the user must be logged in in order to complete the sale process. but after redirecting from bank to above url (VerifyPayment), the user is NOT logged in and the code will return a null exception.
the question is how should I keep user logged in after redirecting from bank to my website?
or how can get user from cookie and sign that user in?
the problem is araised in the process of getting user. we should use this code in order to get user:
var user = System.
Web.
HttpContext.
Current.
GetOwinContext().
GetUserManager<ApplicationUserManager>().
FindById(userId);
note that the correct approach is as above. the following code produces the problem. doNOT use it to obtain current user:
var user = db.Users.Where(u => u.Id == userId).FirstOrDefault();
I have a 2-steps-form (Fancy Name), but, when I submit this form, the validation return false all time, I debugged it and I receive all the parameters I want, but for some reason the isValid is false and get some error in the RadioButton element, this is the code:
This is the forms/Users.php
public function signup()
{
$contryModel = new Application_Model_Country();
$countries = $contryModel->getCountries();
foreach ($countries as $array)
{
if(isset($array['id_country'])){
$countryArr[$array['id_country']] = $array['country'];
}
}
array_unshift($countryArr, '-- Select Your Country --');
$name = new Zend_Form_Element_Text('Name');
$name->setLabel('Name')
->setRequired(true)
->addValidator('NotEmpty');
$lastname = new Zend_Form_Element_Text('LastName');
$lastname->setLabel('Last Name')
->setRequired(true)
->addValidator('NotEmpty');
$email = new Zend_Form_Element_Text('Email');
$email->setLabel('Email')
->setRequired(true)
->addValidator('NotEmpty');
$website = new Zend_Form_Element_Text('Website');
$website->setLabel('Website')
->setRequired(true)
->addValidator('NotEmpty');
$country = new Zend_Form_Element_Select('Country');
$country->setLabel('Country')
->setRequired(true)
->addValidator('NotEmpty')
->addMultiOptions($countryArr);
$city = new Zend_Form_Element_Select('City');
$city->setLabel('City')
->setRequired(true)
->addValidator('NotEmpty')
->addMultiOptions(array('-- Select Your City --'))
->setRegisterInArrayValidator(false)
->setAttrib('disabled',true);
$password = new Zend_Form_Element_Password('Password');
$password->setLabel('Password')
->setRequired(true)
->addValidator('NotEmpty');
$rpassword = new Zend_Form_Element_Password('RepeatPassword');
$rpassword->setLabel('Repeat Password')
->setRequired(true)
->addValidator('NotEmpty');
$why = new Zend_Form_Element_Textarea('Why');
$why->setRequired(true)
->addValidator('NotEmpty')
->setAttrib('cols', '50')
->setAttrib('rows', '4');
$job = new Zend_Form_Element_Text('Job');
$job->setLabel("Job")
->setRequired(true)
->addValidator('NotEmpty');
$boxes = new Application_Model_Colors();
$res = $boxes->getColors();
foreach($res as $colors){
$colorArr[$colors['id']]['color'] = $colors['color'];
$colorArr[$colors['id']]['overColor'] = $colors['overColor'];
}
$color = new Zend_Form_Element_Radio('color');
$color->setLabel('Color')
->addMultiOptions($colorArr)
->addValidator('NotEmpty');
$save = new Zend_Form_Element_Submit('Submit');
$save->setLabel('Save');
$this->addElements(array($name, $lastname, $email, $website, $password, $rpassword, $job, $country, $city, $color, $why, $save));
}
*This is a part of the view * where I format the Radios
<?php
foreach($this->form->color->options as $key=>$colors){
echo "<label><input type='radio' value='$key' name='color'><div class='registrationBoxes' style='background-color:#".$colors['color']."' data-color='".$colors['color']."' data-overColor='".$colors['overColor']."' value='".$colors['color']."'></div></label>";
}
?>
And here is the Controller
public function indexAction()
{
$form = new Application_Form_Users();
$form->signup();
$this->view->form = $form;
if($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if($form->isValid($formData))
{
$formData = $this->getRequest()->getPost();
$name = $formData['Name'];
$lastName = $formData['LastName'];
$email = $formData['Email'];
$website = $formData['Website'];
$password = $formData['Password'];
$rpassword = $formData['RepeatPassword'];
$job = $formData['Job'];
$country = $formData['Country'];
$city = $formData['City'];
$color = $formData['color'];
$why = $formData['Why'];
$date_create = date('Y-m-d H:i:s');
$position = new Application_Model_Country();
$latLong = $position->getLatLong($city);
if($password == $rpassword){
$data = array( 'name'=>$name,
'last_name'=>$lastName,
'email'=>$email,
'website'=>$website,
'password'=>md5($password),
'date_create'=>$date_create,
'job'=>$job,
'country'=>$country,
'city'=>$city,
'color'=>$color,
'why'=>$why,
'latitude'=>$latLong['latitude'],
'longitude'=>$latLong['longitude']
);
$add = new Application_Model_Users();
$res = $add->insertUser($data);
if($res){
$this->view->message = "Registration Successfuly.";
$this->_redirect("/contact");
}else{
$this->view->errorMessage = "We have a problem with your registration, please try again later.";
}
}else{
$this->view->errorMessage = "Password and confirm password don't match.";
$form->populate($formData);
}
} else {
$this->view->errorMessage = "There is an error on your registration, all fields are requried";
$form->populate($formData);
}
}
}
a die(var_dump()) return this:
array(12) {
["Name"]=>
string(9) "Some name"
["LastName"]=>
string(13) "Some lastName"
["Email"]=>
string(21) "Someemail#hotmail.com"
["Password"]=>
string(5) "Some "
["RepeatPassword"]=>
string(5) "Some "
["Website"]=>
string(12) "Some website"
["Job"]=>
string(8) "Some job"
["Country"]=>
string(1) "7"
["City"]=>
string(3) "434"
["color"]=>
string(1) "3"
["Why"]=>
string(10) "Emotional!"
["Submit"]=>
string(4) "Save"
}
As you can see, all the parameters are coming and with value, but for no reason the isValid is returning false, some idea guys?
Thanks.-
EDIT
This is a part of the Zend/form.php code required by Tonunu
public function __construct ($options = null)
{
if (is_array($options)) {
$this->setOptions($options);
} elseif ($options instanceof Zend_Config) {
$this->setConfig($options);
}
// Extensions...
$this->init();
$this->loadDefaultDecorators();
}
public function __clone ()
{
$elements = array();
foreach ($this->getElements() as $name => $element) {
$elements[] = clone $element;
}
$this->setElements($elements);
$subForms = array();
foreach ($this->getSubForms() as $name => $subForm) {
$subForms[$name] = clone $subForm;
}
$this->setSubForms($subForms);
$displayGroups = array();
foreach ($this->_displayGroups as $group) {
$clone = clone $group;
$elements = array();
foreach ($clone->getElements() as $name => $e) {
$elements[] = $this->getElement($name);
}
$clone->setElements($elements);
$displayGroups[] = $clone;
}
$this->setDisplayGroups($displayGroups);
}
public function setOptions (array $options)
{
if (isset($options['prefixPath'])) {
$this->addPrefixPaths($options['prefixPath']);
unset($options['prefixPath']);
}
if (isset($options['elementPrefixPath'])) {
$this->addElementPrefixPaths($options['elementPrefixPath']);
unset($options['elementPrefixPath']);
}
if (isset($options['displayGroupPrefixPath'])) {
$this->addDisplayGroupPrefixPaths(
$options['displayGroupPrefixPath']);
unset($options['displayGroupPrefixPath']);
}
if (isset($options['elementDecorators'])) {
$this->_elementDecorators = $options['elementDecorators'];
unset($options['elementDecorators']);
}
if (isset($options['elements'])) {
$this->setElements($options['elements']);
unset($options['elements']);
}
if (isset($options['defaultDisplayGroupClass'])) {
$this->setDefaultDisplayGroupClass(
$options['defaultDisplayGroupClass']);
unset($options['defaultDisplayGroupClass']);
}
if (isset($options['displayGroupDecorators'])) {
$displayGroupDecorators = $options['displayGroupDecorators'];
unset($options['displayGroupDecorators']);
}
if (isset($options['elementsBelongTo'])) {
$elementsBelongTo = $options['elementsBelongTo'];
unset($options['elementsBelongTo']);
}
if (isset($options['attribs'])) {
$this->addAttribs($options['attribs']);
unset($options['attribs']);
}
$forbidden = array('Options', 'Config', 'PluginLoader', 'SubForms',
'View', 'Translator', 'Attrib', 'Default');
foreach ($options as $key => $value) {
$normalized = ucfirst($key);
if (in_array($normalized, $forbidden)) {
continue;
}
$method = 'set' . $normalized;
if (method_exists($this, $method)) {
$this->$method($value);
} else {
$this->setAttrib($key, $value);
}
}
if (isset($displayGroupDecorators)) {
$this->setDisplayGroupDecorators($displayGroupDecorators);
}
if (isset($elementsBelongTo)) {
$this->setElementsBelongTo($elementsBelongTo);
}
return $this;
}
In order to check if your form is valid, you have to put your data into it, using this method !
$form->setData($formData)
and then you can ask for validation
$form->isValid()
So what you need is :
$formData = $this->getRequest()->getPost();
$form->setData($formData);
if($form->isValid()){
//Blablablabla
}
I am try to do MessageList in blackberry using midlet, but whatever I do some expection comes up. Right now am getting NullPointerException. Here is the code
EncodedImage indicatorIcon = EncodedImage.getEncodedImageResource("img/indicator.png");
ApplicationIcon applicationIcon = new ApplicationIcon(indicatorIcon);
ApplicationIndicatorRegistry.getInstance().register(applicationIcon, false, false);
ApplicationMessageFolderRegistry reg = ApplicationMessageFolderRegistry.getInstance();
MessageListStore messageStore = MessageListStore.getInstance();
if(reg.getApplicationFolder(INBOX_FOLDER_ID) == null)
{
ApplicationDescriptor daemonDescr = ApplicationDescriptor.currentApplicationDescriptor();
String APPLICATION_NAME = "TestAPP";
ApplicationDescriptor mainDescr = new ApplicationDescriptor(daemonDescr, APPLICATION_NAME, new String[] {});
ApplicationFolderIntegrationConfig inboxIntegration = new ApplicationFolderIntegrationConfig(true, true, mainDescr);
ApplicationFolderIntegrationConfig deletedIntegration = new ApplicationFolderIntegrationConfig(false);
ApplicationMessageFolder inbox = reg.registerFolder(MyApp.INBOX_FOLDER_ID, "Inbox", messageStore.getInboxMessages(),
inboxIntegration);
ApplicationMessageFolder deleted = reg.registerFolder(MyApp.DELETED_FOLDER_ID, "Deleted Messages", messageStore.getDeletedMessages(), deletedIntegration);
messageStore.setFolders(inbox, deleted);
}
DemoMessage message = new DemoMessage();
String name = "John";
message.setSender(name);
message.setSubject("Hello from " + name);
message.setMessage("Hello Chris. This is " + name + ". How are you? Hope to see you at the conference!");
message.setReceivedTime(System.currentTimeMillis());
messageStore.addInboxMessage(message);
messageStore.getInboxFolder().fireElementAdded(message);
Can someone suggest me a simple MessageList sample for midlet to just show a String in MessageList and custom ApplicationIndicator value. If possible OnClick of message bring back the midlet from background.
use the following code:
static class OpenContextMenu extends ApplicationMenuItem {
public OpenContextMenu( int order ) {
super( order );
}
public Object run( Object context ) {
if( context instanceof NewMessage ) {
try {
NewMessage message = (NewMessage) context;
if( message.isNew() ) {
message.markRead();
ApplicationMessageFolderRegistry reg = ApplicationMessageFolderRegistry.getInstance();
ApplicationMessageFolder folder = reg.getApplicationFolder( Mes
sageList.INBOX_FOLDER_ID );
folder.fireElementUpdated( message, message );
//changeIndicator(-1);
}
Inbox inbox = message.getInbox();
Template template = inbox.getTemplate();
//Launch the mainscreen
UiApplication.getUiApplication().requestForeground();
}
catch (Exception ex) {
Dialog.alert();
}
}
return context;
}
public String toString() {
return "Name of the menu item";
}
}
I want to acces alarm. in my application i have successfully accessed calender and have set the appointment but how i can access alarm. please help me. following is my code
public class Alarm
{
private Event event;
public void myAlarm()
{
try
{
EventList eventList = (EventList)PIM.getInstance().
openPIMList(PIM.EVENT_LIST, PIM.WRITE_ONLY);
event = eventList.createEvent();
event.addString(event.SUMMARY, PIMItem.ATTR_NONE, "My alarm");
event.addString(event.LOCATION, PIMItem.ATTR_NONE, "My Location");
event.addDate(event.END, PIMItem.ATTR_NONE,
System.currentTimeMillis()+360000);
event.addDate(event.START, PIMItem.ATTR_NONE,
System.currentTimeMillis()+120000);
event.commit();
}//end of try block
catch(Exception e){}
}//end of method myAlarm
}//end of main class Alarm
EventList evList = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST,
PIM.READ_WRITE);
BlackBerryEvent ev = (BlackBerryEvent) evList.createEvent();
if (evList.isSupportedField(BlackBerryEvent.ALARM)) {
ev.addInt(BlackBerryEvent.ALARM, BlackBerryEvent.ATTR_NONE, 180); //3 min = 180
//if this field has a value of 180, then the alarm first occurs 180 seconds before the
date/time value specified by Event.START
}
if(field == save)
{
try
{
events = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST,PIM.READ_WRITE );
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++++++++++++++++++"+e);
return;
}
Event event = events.createEvent();
if( events.isSupportedField( Event.SUMMARY ) )
event.addString( Event.SUMMARY, PIMItem.ATTR_NONE, "Meeting with John" );
if( events.isSupportedField( Event.LOCATION ) )
event.addString( Event.LOCATION, PIMItem.ATTR_NONE, "Amritsar" );
if( events.isSupportedField( Event.START ) )
event.addDate( Event.START, PIMItem.ATTR_NONE, aDate.getDate()+60000);
System.out.println("System.currentTimeMillis()+60000 : "+System.currentTimeMillis()+60000);
if( events.isSupportedField( Event.END ) )
event.addDate( Event.END, PIMItem.ATTR_NONE, aDate.getDate()+120000);
System.out.println("System.currentTimeMillis()+120000 : "+System.currentTimeMillis());
if( events.isSupportedField( Event.ALARM ) )
{
event.addInt( Event.ALARM, PIMItem.ATTR_NONE, 900);
}
if( events.isSupportedField( Event.NOTE ) )
event.addString( Event.NOTE, PIMItem.ATTR_NONE,"I phoned on Monday to book this meeting" );
try
{
if( events.maxCategories() != 0 && events.isCategory( "Work" ) )
event.addToCategory( "Work" );
}
catch (PIMException e1)
{
e1.printStackTrace();
}
try
{
event.commit();
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++++++++++++++++++"+e);
}
try
{
events.close();
}
catch( PIMException e )
{
System.out.println("++++++++++++++++++----------------"+e);
}
}