BlackBerry - How to create alarm event? - blackberry

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);
}
}

Related

Xamarin Android Take picture intent save 0b file

i'm trying to take a pitcure with camera startin from fileupload of webview.
All code works for file chooser, but when i take a pitcure with camera, i found a 0b file in the directory where i create the temp file.
Someone can help me?
Here my code for customchromeclient filechooser event:
public override bool OnShowFileChooser(Android.Webkit.WebView webView, Android.Webkit.IValueCallback filePathCallback, FileChooserParams fileChooserParams)
{
string[] type = fileChooserParams.GetAcceptTypes();
this.mFilePathCallback = filePathCallback;
px_MyActivity.mFilePathCallback = filePathCallback;
if (string.Join("/", type).Contains("jpg") || string.Join("/", type).Contains("image"))
{
try
{
Intent takePictureIntent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
if (takePictureIntent.ResolveActivity(px_MyActivity.PackageManager) != null) {
Java.IO.File photoFile = null;
try
{
photoFile = createImageFile();
}
catch(Exception e)
{
}
if (photoFile != null) {
mCameraPhotoPath = "file:" + photoFile.AbsolutePath;
//takePictureIntent.PutExtra(Android.Provider.MediaStore.ExtraOutput, photoFile);
px_MyActivity.mCameraPhotoPath = Android.Net.Uri.FromFile(photoFile); ;
} else {
takePictureIntent = null;
}
}
Intent contentSelectionIntent = new Intent(Intent.ActionGetContent);
contentSelectionIntent.AddCategory(Intent.CategoryOpenable);
contentSelectionIntent.SetType("image/*");
Intent[] intentArray;
if(takePictureIntent != null) {
intentArray = new Intent[]{takePictureIntent};
} else {
intentArray = new Intent[0];
}
//Intent chooserIntent = new Intent(Intent.ActionChooser);
Intent chooserIntent = Intent.CreateChooser(contentSelectionIntent, "Carica Foto");
chooserIntent.PutExtra(Intent.ExtraIntent, contentSelectionIntent);
chooserIntent.PutExtra(Intent.ExtraTitle, "Carica Foto");
chooserIntent.PutExtra(Intent.ExtraInitialIntents, intentArray);
px_MyActivity.StartActivityForResult(chooserIntent, PHOTO_REQUEST);
}catch(Exception ex){
}
}
else if (string.Join("/", type).Contains("mpg"))
{
Intent takePictureIntent = new Intent(Android.Provider.MediaStore.ActionVideoCapture);
}
else
{
Intent chooserIntent = fileChooserParams.CreateIntent();
chooserIntent.SetType("file/*");
chooserIntent.AddCategory(Intent.CategoryOpenable);
px_MyActivity.StartActivity(Intent.CreateChooser(chooserIntent, "File Chooser"), FILECHOOSER_RESULTCODE, this.OnFileChooserEnd);
}
return true;
}
private Java.IO.File createImageFile(){
// Create an image file name
string timeStamp = Android.OS.SystemClock.CurrentThreadTimeMillis().ToString();
string imageFileName = "JPEG_" + timeStamp + "_";
Java.IO.File storageDir = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory.Path);
Java.IO.File imageFile = Java.IO.File.CreateTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
return imageFile;
}
and here the code for avtivityresult:
protected override void OnActivityResult(int requestCode, Result resultVal, Android.Content.Intent data)
{
if (resultVal == Result.Ok)
{
if (requestCode == SPEECH)
{
var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
if (matches.Count != 0)
{
string xResult = matches[0];
if (xResult.Length > 500)
{
xResult = xResult.Substring(0, 500);
}
Xamarin.Forms.MessagingCenter.Send(this, "SpeechEnd", xResult);
}
}else if (requestCode == FILECHOOSER_RESULTCODE)
{
}else if (requestCode == PHOTO_REQUEST)
{
if (mFilePathCallback == null)
{
base.OnActivityResult(requestCode, resultVal, data);
return;
}
Android.Net.Uri[] result = null;
if (data == null)
{
if (mCameraPhotoPath != null)
{
result = new Android.Net.Uri[] { mCameraPhotoPath };
}
}
else
{
string xDataString = data.DataString;
if (xDataString != null)
{
result = new Android.Net.Uri[] { Android.Net.Uri.Parse(xDataString) };
}
else
{
Android.Graphics.Bitmap xImage = (Android.Graphics.Bitmap)data.Extras.Get("data");
try
{
//if(Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, Android.Manifest.Permission.ReadExternalStorage) == Permission.Granted)
//{
// var xStream = new System.IO.FileStream(mCameraPhotoPath.Path, System.IO.FileMode.OpenOrCreate);
// xImage.Compress(Bitmap.CompressFormat.Jpeg, 100, xStream);
// xStream.Flush();
// xStream.Close();
// //string path = Android.Provider.MediaStore.Images.Media.InsertImage(ContentResolver, xImage, "Title", "prova 1");
// // string path = Android.Provider.MediaStore.Images.Media.InsertImage(ContentResolver, mCameraPhotoPath.Path, "Title.jpg", "prova 1");
//}
if (mCameraPhotoPath != null)
{
result = new Android.Net.Uri[] { mCameraPhotoPath };
}
}
catch (Java.IO.IOException e)
{
e.PrintStackTrace();
}
}
}
//mFilePathCallback.OnReceiveValue(Android.Webkit.WebChromeClient.FileChooserParams.ParseResult((int)resultVal, data));
mFilePathCallback.OnReceiveValue(result);
mFilePathCallback = null;
}
}else{
if (requestCode == PHOTO_REQUEST)
{
mFilePathCallback.OnReceiveValue(Android.Webkit.WebChromeClient.FileChooserParams.ParseResult((int)resultVal, null));
}
}

Flash of previous page while navigating between pages in react js application

I am developing a react js application for ios and android. In my application while navigating from one page to another,a flash of previous page is displaying for 1 second and then my next page is loading.This issue is prevalent only in ios app.
Issue does not appear while checking in browser safari,chrome.Only in app
Please provide solution.
We are not using react native and react router.
Few pages are developed in reactjs and integrated in to an existing mobile app.
In the above code:
else {
console.log('clicked');
window.location.href = path + '?id=' + id + '&time=' `window.sessionStorage.getItem('time') + '&prodId=' + productId + '&qty=' + `qty + '&storeCall=true';
}
here we are navigating to another jsx page with window.location.href
While navigating a getting issues in ios app.Flash of previous page showing up for a second
import React from 'react';
import Copyright from './Copyright.jsx';
import { browserHistory } from 'react-router';
import axios from 'axios';
import envConstant from '../../../../../config/labelConstants.js';
import { ClipLoader } from 'react-spinners';
var x=0;
let submitOrder, flag = "false", footerBtn = '', vendor;
let closeFunc;
class Footer extends React.Component {
constructor(props) {
super(props);
this.orderSubmit = this.orderSubmit.bind(this);
this.validateSubmit = this.validateSubmit.bind(this);
this.validateNetwork = this.validateNetwork.bind(this);
this.disableBtn = this.disableBtn.bind(this);
this.state = {
data: 'Initial data....',
price: 'total',
loading:false
}
this.propTypes = {
alertFunc: React.PropTypes.func,
couponAvail: React.PropTypes.func,
alertClose:React.PropTypes.func
};
};
validateSubmit() {
const react = this;
var submit = false;
var phoneNum;
var fname = this.props.UserDetails.refs.fname.value;
var lname = this.props.UserDetails.refs.lname.value;
var phone = this.props.UserDetails.refs.phone.value.replace(/[-.]/gi, '');
if (phone != null) {
phoneNum = phone.toString();
}
var email = this.props.UserDetails.refs.email.value;
var agree = window.sessionStorage.getItem('agree');
submitOrder = {};
let prodId, qty;
if (null == window.sessionStorage.getItem('prodID') && null == window.sessionStorage.getItem('qty')) {
prodId = window.sessionStorage.getItem('initprodID');
qty = 1;
} else {
prodId = window.sessionStorage.getItem('prodID');
qty = window.sessionStorage.getItem('qty');
}
submitOrder = {
fname: this.props.UserDetails.refs.fname.value,
lname: this.props.UserDetails.refs.lname.value,
coupon: window.sessionStorage.getItem('successCoupon'),
email: this.props.UserDetails.refs.email.value,
phoneNum: this.props.UserDetails.refs.phone.value.replace(/[-.]/gi, ''),
id: window.sessionStorage.getItem('id'),
qty: qty,
prodID: prodId,
emailOptIn: window.sessionStorage.getItem('emailOptIn'),
smsOptIn: window.sessionStorage.getItem('smsOptIn'),
time: window.sessionStorage.getItem('time')
};
if (fname == null || fname == '') {
this.props.alertFunc(envConstant.enterDetails,react.props.UserDetails.refs.fname);
submit = false;
return false;
}
if (lname == null || lname == '') {
this.props.alertFunc(envConstant.enterDetails,react.props.UserDetails.refs.lname);
submit = false;
return false;
}
if (phoneNum == null || phoneNum == '') {
this.props.alertFunc(envConstant.enterDetails,react.props.UserDetails.refs.phone);
submit = false;
return false;
}
if (email == null || email == '') {
this.props.alertFunc(envConstant.enterDetails,react.props.UserDetails.refs.email);
submit = false;
return false;
}
if ('' != fname || null != fname || '' == lname || null != lname) {
submit = true;
}
if (null != fname || '' != fname) {
const re = /^[a-zA-Z\ ]*$/;
if (!re.test(fname)) {
this.props.alertFunc(envConstant.invalidName,react.props.UserDetails.refs.fname);
submit = false;
return false;
} else {
submit = true;
}
}
if (null != lname || '' != lname) {
const re = /^[a-zA-Z\'\-\. ]*$/;
if (!re.test(lname)) {
this.props.alertFunc(envConstant.invalidName,react.props.UserDetails.refs.lname);
submit = false;
return false;
} else {
submit = true;
}
}
if (null != phoneNum || '' != phoneNum) {
if (vendor == "boots") {
if (phoneNum.length != "11") {
this.props.alertFunc(envConstant.invalidPhnum,react.props.UserDetails.refs.phone);
submit = false;
return false;
} else {
submit = true;
}
} else if (vendor == "roi") {
const re = /^[0]+[0-9]*$/;
if (phoneNum.length != "11" || !re.test(phoneNum)) {
this.props.alertFunc(envConstant.invalidPhnum,react.props.UserDetails.refs.phone);
submit = false;
return false;
} else {
submit = true;
}
} else {
if (phoneNum.length != "10") {
this.props.alertFunc(envConstant.invalidPhnum,react.props.UserDetails.refs.phone);
submit = false;
return false;
} else {
submit = true;
}
}
}
if (null != email || '' != email) {
const re = /^([a-zA-Z0-9_\.\-])+\#(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!re.test(email)) {
this.props.alertFunc(envConstant.invalidEmail,react.props.UserDetails.refs.email);
submit = false;
return false;
} else {
submit = true;
}
}
if (agree == "false" || null == agree) {
this.props.alertFunc(envConstant.agreeTerms);
submit = false;
return false;
}
if (submit == true) {
return true;
}
}
validateNetwork() {
var hasConn = window.navigator.onLine;
if (hasConn) {
return hasConn;
}
else {
this.props.alertFunc(envConstant.networkFailure);
}
}
orderSubmit(e) {
const react = this;
if (this.props.footer == envConstant.submitFoot) {
window.sessionStorage.setItem('id', this.props.id);
if (this.validateNetwork()) {
if (this.validateSubmit()) {
axios({
method: 'post',
url: react.props.urlValue + '/inputFields',
data: submitOrder
}).then((response) => {
this.setState({loading:true});
window.location.href = react.props.path;
});
}
}
}
if (this.props.footer == envConstant.orderInfoFoot) {
if (this.validateNetwork()) {
let qty, productId;
this.setState({loading:true});
if (null == window.sessionStorage.getItem('qty') || 'null' == `window.sessionStorage.getItem('qty')) {`
qty = 1;
productId = window.sessionStorage.getItem('initprodID');
} else {
qty = window.sessionStorage.getItem('qty');
productId = window.sessionStorage.getItem('prodID');
}
let path = this.props.path;
let id = this.props.id;
if (null != window.sessionStorage.getItem('coupon') && "null" != `window.sessionStorage.getItem('coupon')) {`
if (window.sessionStorage.getItem('errorcode') == '' && null != `window.sessionStorage.getItem('coupon') &&` `window.sessionStorage.getItem('couponApplied') == "true") {`
setTimeout(function () {
if (window.sessionStorage.getItem('status1') != 'failure') {
window.location.href = path + '?id=' + id + '&time=' + `window.sessionStorage.getItem('time') + '&prodId=' + productId + '&qty=' +` `qty + '&storeCall=true';`
}
},1500);
}
}
else {
console.log('clicked');
window.location.href = path + '?id=' + id + '&time=' + `window.sessionStorage.getItem('time') + '&prodId=' + productId + '&qty=' +` `qty + '&storeCall=true';`
}
}
}
if (this.props.footer == envConstant.ThankyouFoot) {
let callBackUrl = this.props.callBackUrl;
if (window.navigator.userAgent.includes("iPhone")) {
window.location = "QP_DONE:DONE";
} else {
try {
window.quickprint.onCheckoutComplete();
} catch (e) {
if (undefined != callBackUrl && '' != callBackUrl && null != callBackUrl) {
if (callBackUrl.includes('?')) {
window.location = callBackUrl + '?action=done';
} else {
window.location = callBackUrl + '&action=done';
}
}
}
}
}
}
componentDidMount() {
let footerHeight = this.refs.footerHeight.clientHeight;
window.sessionStorage.setItem('footerHeight', footerHeight);
}
disableBtn(id) {
window.sessionStorage.setItem('disable', "true");
if(window.sessionStorage.getItem('alert1'+id)=="0" || `window.sessionStorage.getItem('alert1'+id)=="1" || `window.sessionStorage.getItem('alert1'+id)==1){
alert(envConstant.priceInvalid);
}else{
x=0;
window.sessionStorage.setItem('alert1'+id,x++);
}
//this.props.alertFunc(envConstant.priceInvalid)
}
render() {
vendor = this.props.vendor;
let copyrightsWrapper;
if (vendor != "ts" && vendor != "roi") {
copyrightsWrapper = (
<Copyright copyRightMessage={this.props.copyRightMessage} />
);
}
if (typeof window !== 'undefined') {
window.sessionStorage.setItem('callBackUrl',this.props.callBackUrl);
if (window.sessionStorage.getItem('status') == "success" || `window.sessionStorage.getItem('status') == "") {`
if ((window.sessionStorage.getItem('status1') != "failure" || `window.sessionStorage.getItem('couponApplied') == "false") && `window.sessionStorage.getItem('flagDrop') != "true" &&` `window.sessionStorage.getItem('couponFocus') != "true") {
var discTotal = `window.sessionStorage.getItem('discount').split(this.props.currency);`
if (parseInt(discTotal[1]) > 998) {
window.sessionStorage.setItem('alert1'+this.props.id,x++);
this.disableBtn(this.props.id);
} else {
window.sessionStorage.setItem('disable', "false");
}
}
}
if (window.sessionStorage.getItem('status') == null) {
if (window.sessionStorage.getItem('invalid') != 'true') {
if (null == window.sessionStorage.getItem('total')) {
var initTotal = `window.sessionStorage.getItem('inittotal').split(this.props.currency);`
if (parseInt(initTotal[1]) > 998) {
window.sessionStorage.setItem('alert1'+this.props.id,1);
this.disableBtn(this.props.id);
} else {
window.sessionStorage.setItem('disable', "false");
}
} else {
var prodTotal = `window.sessionStorage.getItem('total').split(this.props.currency);`
if (parseInt(prodTotal[1]) > 998) {
window.sessionStorage.setItem('alert1'+this.props.id,1);
this.disableBtn(this.props.id);
} else {
window.sessionStorage.setItem('disable', "false");
}
}
}
}
if (window.sessionStorage.getItem('disable') == "true") {
footerBtn = (
<button type="button"
className="btn-off supp-color btn-w1" `disabled="disabled"> {this.props.footer}</button>`
);
} else {
footerBtn = (
<button ref="footerBtn" type="button" className="btn-on supp-color btn-`w1" onClick={this.orderSubmit}>{this.props.footer}</button>`
);
}
}else{
footerBtn = (
<button ref="footerBtn" type="button" className="btn-on supp-color btn-w1" >{this.props.footer}</button>
);
}
return (
<div className="op-footer footer_height" ref="footerHeight" id="footerValue">
{copyrightsWrapper}
<div className="background-white">
<div className={'sweet-loading '+ this.state.loading}>
<ClipLoader color={'#a0a0a0'} loading={this.state.loading}/>
</div>
{footerBtn}
</div>
</div>
);
}
}
export default Footer;

asp.net-MVC Unexplained Production Exception

After moving my application to production, I get the regular Object reference not set to an instance of an object. exception logged in my event viewer.
This exception occurs intermittently few times a day, the problem is that I cannot put my hand on the problem, the logged exception details are not helpful, as there are no code line numbers included in the stack trace.
The Exception occurs on an action in my home controller which is the entry point action for each user arriving at the web site.
Can anyone help me reason with the below trace:
ERROR => Object reference not set to an instance of an object.
(XXX.XXX.Web.Controllers.HomeController.Index)
(
<>c__DisplayClass2b.<BeginInvokeAction>b__1c =>
<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32 =>
<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f =>
AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d =>
WrappedAsyncResult`2.CallEndDelegate =>
AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39 =>
ControllerActionInvoker.InvokeActionMethod =>
ReflectedActionDescriptor.Execute =>
<no type>.lambda_method => HomeController.Index )
System.NullReferenceException: Object reference not set to an instance of an object.
at XXXX.XXXX.Web.Controllers.HomeController.Index()
Code:
[SSOAuthorize]
public ActionResult Index()
{
try
{
ViewBag.ShowXXXAccountPrompt = false;
ViewBag.IsErrored = "false";
#region "Session Check"
if (_webHttpContext == null)
{
return RedirectToAction("signout", "Federation");
}
if (_webHttpContext.Session == null)
{
return RedirectToAction("signout", "Federation");
}
if (_webHttpContext.Session.PortalUser == null)
{
return RedirectToAction("signout", "Federation");
}
#endregion
if (_webHttpContext.Session.PortalUser != null)
{
if (!string.IsNullOrEmpty(_webHttpContext.Session.PortalUser.UserName))
{
var user = _usersManagementService.GetUserByUsername(_webHttpContext.Session.PortalUser.UserName);
var latestsubline = _subscriptionLineService.GetLatestLineByUserName(_webHttpContext.Session.PortalUser.UserName);
var isDualAccount = latestsubline == null ? false : latestsubline.Action == (int)Entities.SubscriptionLineAction.Activate? latestsubline.IsDualAccount : false;
isDualAccount = isDualAccount == null ? false : isDualAccount;
if(user == null)
{
//whenever there is no account Just Create it, the subscriptionLines table is irrelevant
_usersManagementService.CreateUser(_webHttpContext.Session.PortalUser.UserName, isDualAccount);
}
if (user.Status == AccountStatus.Inactive)
{
//Account Re-Activation Logic
if (_usersManagementService.CreateAccountHistory(user))
{
user.FirstLogonOn = DateTime.Now;
user.DeactivatedOn = null;
user.Status = AccountStatus.Active;
user.IsDualAccount = isDualAccount;
_usersManagementService.UpdateAccount(user);
#region "Check XXX Dual Account"
try
{
if (_webHttpContext.Session.MultipleAccountDialogueInformed == false)
{
_webHttpContext.Session.MultipleAccountDialogueInformed = true;
if (user.IsDualAccount == true)
{
ViewBag.ShowXXXAccountPrompt = true;
}
else
{
ViewBag.ShowXXXAccountPrompt = false;
}
}
}
catch (Exception ex)
{
_logger.Log(LogLevel.Error, "XXX Account Service _ " + ex.Message, ex);
}
#endregion
}
else
{
ViewBag.IsErrored = "true";
return View(_webHttpContext.Account);
}
}
else
{
#region "Check XXX Dual Account"
try
{
if (_webHttpContext.Session.MultipleAccountDialogueInformed == false)
{
_webHttpContext.Session.MultipleAccountDialogueInformed = true;
if (user.IsDualAccount == true)
{
ViewBag.ShowXXXAccountPrompt = true;
}
else
{
ViewBag.ShowXXXAccountPrompt = false;
}
}
}
catch (Exception ex)
{
_logger.Log(LogLevel.Error, "XXX Account Service _ " + ex.Message, ex);
}
#endregion
}
_webHttpContext.BrowserDetails.OperatingSystem = Entities.OperatingSystem.MacinXXXh;
_webHttpContext.Session.PortalUser.Id = user.Id;
if (_webHttpContext.BrowserDetails.OperatingSystem == Entities.OperatingSystem.Windows)
{
ViewBag.ProductType = "ZZZ";
var YYYInstallsDetails = GetYYYInstallsDetails(0);
ViewBag.RemainingInstallCount = YYYInstallsDetails.NumberOfSeatsAvailable;
ViewBag.YYYInstallsDetails = YYYInstallsDetails.YYYCustomersLicenseDetailsList;
ViewBag.YYYInstallsDetailsCount = YYYInstallsDetails.YYYCustomersLicenseDetailsList.Count;
ViewBag.DownloadPageUrl = getDownloadPageUrl(ProductType.ComputerProtectionNT);
ViewBag.ProductId = (int)ProductType.ComputerProtectionNT;
}
else if (_webHttpContext.BrowserDetails.OperatingSystem == Entities.OperatingSystem.MacinXXXh)
{
ViewBag.ProductType = "MacZZZ";
var YYYInstallsDetails = GetYYYInstallsDetails(1);
ViewBag.RemainingInstallCount = YYYInstallsDetails.NumberOfSeatsAvailable;
ViewBag.YYYInstallsDetails = YYYInstallsDetails.YYYCustomersLicenseDetailsList;
ViewBag.YYYInstallsDetailsCount = YYYInstallsDetails.YYYCustomersLicenseDetailsList.Count;
ViewBag.DownloadPageUrl = getDownloadPageUrl(ProductType.ComputerProtectionOSX);
ViewBag.ProductId = (int)ProductType.ComputerProtectionOSX;
}
else if (_webHttpContext.BrowserDetails.OperatingSystem == Entities.OperatingSystem.Other)
{
ViewBag.ProductType = "AndroidZZZ";
var YYYInstallsDetails = GetYYYInstallsDetails(2);
ViewBag.RemainingInstallCount = YYYInstallsDetails.NumberOfSeatsAvailable;
ViewBag.YYYInstallsDetails = YYYInstallsDetails.YYYCustomersLicenseDetailsList;
ViewBag.YYYInstallsDetailsCount = YYYInstallsDetails.YYYCustomersLicenseDetailsList.Count;
ViewBag.DownloadPageUrl = getDownloadPageUrl(ProductType.ComputerProtectionAndroid);
ViewBag.ProductId = (int)ProductType.ComputerProtectionAndroid;
}
ViewBag.ZZZInstallUrl = PortalConfig.ZZZInstallUrl;
ViewBag.ScInstallUrl = PortalConfig.SafeCentralInstallUrl;
ViewBag.MacZZZInstallUrl = PortalConfig.MacZZZInstallUrl;
ViewBag.TTTTEmail = _webHttpContext.Session.PortalUser.UserName;
}
else // if primary username coming back from sso is empty
{
return RedirectToAction("signout", "Federation");
}
}
else // if the portal user is null
{
return RedirectToAction("signout", "Federation");
}
}
catch (Exception ex)
{
ViewBag.IsErrored = "true";
_logger.Log(LogLevel.Error, ex.Message, ex);
}
return View(_webHttpContext.Account);
}

Putting contact info into Phone Book from Blackberry

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 ) {
}

Stuck up with MessageList in Blackberry

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";
}
}

Resources