Open compose email window directly in blackberry [duplicate] - blackberry

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to open the Blackberry email app, ready to compose an email to a given address?
I am clicking on a button. On button click, user should move to "Compose email" screen.

MessageArguments ma = new MessageArguments(MessageArguments.ARG_NEW, <recipients>, <subject>, <body>);
//Alternatively, if you don't want to provide default values: ma = new MessageArguments(MessageArguments.ARG_NEW);
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, ma);

this is working fine , try this,
public void SendMail()
{
String htmlContent = "Body part";
Message msg = new Message();
try
{
final Address address = new Address("","");
Address[] addresses = {address};
msg.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, addresses);
msg.setContent(htmlContent);
msg.setSubject("Subject");
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(msg));
}
catch (AddressException e)
{
e.printStackTrace();
System.out.println("AddressException -->"+e.getMessage());
}
catch (MessagingException e)
{
e.printStackTrace();
System.out.println("MessagingException -->"+e.getMessage());
}
}

Related

How to display data (which has just been inserted in database) in a TextView?

The attached photo is a representation of my layout.I need to enter the first and last name in the EditTexts. And by pressing the Insert Button, the info is saved to the database. (This part I managed to do) However, on clicking the Show button, the entered input is to be displayed in the TextView which consists of the firstname & lastname. Attached photo
to upload your data into remote database you can use this code
//enregistrement des donnees dans la base de donnees
WebClient client = new WebClient();
Uri uri = new Uri("http://test.com/login.php");
NameValueCollection parameters = new NameValueCollection();
parameters.Add("Email", email);
parameters.Add("Password", password);
client.UploadValuesCompleted += Client_UploadValuesCompleted;
client.UploadValuesAsync(uri, parameters);
it will generate this method
private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
{
if (Encoding.UTF8.GetString(e.Result) == "success!!!")
{
Toast.MakeText(this, "success!!!", ToastLength.Long).Show();
}
else if (Encoding.UTF8.GetString(e.Result) == "failed!!!")
{
Toast.MakeText(this, "failed!!!", ToastLength.Long).Show();
}
}
and to retrieve your data you can use code
articles = new JavaList<ModelArticle>();
mWebClient = new WebClient();
mUrl = new Uri(urlAddress);
mWebClient.DownloadDataAsync("your url");
mWebClient.DownloadDataCompleted += MWebClient_DownloadDataCompleted;
it will generate this method
private void MWebClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
RunOnUiThread(() =>
{
try
{
string json = Encoding.UTF8.GetString(e.Result);
articles = JsonConvert.DeserializeObject<JavaList<ModelArticle>>(json);
}
catch (Exception exception)
{
Toast.MakeText(this, " Vueillez verifier votre connexion a internet puis reessayer ", ToastLength.Short).Show();
}
});
}
now your result is in the javalist articles don't forget to create a model of your json result

Card Reader Program works in Local system But not from IIS server

I developed a card reader application using ASP.net MVC5. The card reader used by is HID OMNIKEY 3121. When the card is inserted this application will read the name,gender,dob etc that is encoded in the chip. This is working fine in my local system and I am able to show it in a view.
Then I publish the same to IIS in a server. Then I call the MVC website from my local(client) system. The card reader is connected to the local system but when click the read data it is giving a blank page.
Any configuration issue? Please guide me
Edited
Controller
public class cardController : Controller
{
public ActionResult Index()
{
try
{
ReaderManagement readerMgr = new ReaderManagement();
readerMgr.EstablishContext();//extablishing card connection API
try
{
readerMgr.DiscoverReaders(); //discover card reader connected
}
catch(Exception ex)
{
return RedirectToAction("Nocard", "card");
}
PCSCReader[] readers = readerMgr.Readers;
PCSCReader selectedReader = readerMgr.SelectReaderByName(readers[0].ReaderName);
//Other select methods may be called...
selectedReader.IsConnected();
IDCardWrapper.LoadConfiguration();
bool IsCardConnected = selectedReader.IsConnected();
bool isContactless;
if (IsCardConnected) isContactless = selectedReader.IsContactless();
if (!IsCardConnected)
{
readerMgr.SelectReaderByName(readers[0].ReaderName);
try
{
selectedReader.Connect(readerMgr.Context);
}
catch(Exception ex)
{
return RedirectToAction("Nocard", "card");
}
}
CardInfo cardInfo = selectedReader.GetCardInfo();
try
{
PublicDataFacade publicDataFacade = selectedReader.GetPublicDataFacade();
CardHolderPublicData publicData = publicDataFacade.ReadPublicData(true, true, true, true, false);
ViewBag.sex = PublicDataUtils.GetSex(Utils.ByteArrayToUTF8String(publicData.Sex));
ViewBag.maritalstatus = PublicDataUtils.GetMaritalStatus(Utils.ByteArrayToHex(publicData.MaritalStatus, ""));
ViewBag.sponsortype = PublicDataUtils.GetSponsorType(Utils.ByteArrayToHex(publicData.SponsorType, ""));
ViewBag.dob = Utils.ByteArrayToStringDate(publicData.DateOfBirth);
ViewBag.fullname = PublicDataUtils.RemoveCommas(Utils.ByteArrayToUTF8String(publicData.FullName));
ViewBag.arabicname = PublicDataUtils.RemoveCommas(Utils.ByteArrayToUTF8String(publicData.ArabicFullName));
}
readerMgr.CloseContext();
}
catch (Exception ex) //(MiddlewareException ex)
{
}
return View();
}
View
Simply show the viewbag data assigned.
You can't access a local device (like a smart card reader) form a web site.
You'll have to install a desktop application on the client computer (as stated by #Ashley and #Basic) : Chrome App or Windows App for instance.

initiateCall option not working on blackberry device

I've used below code for call option when use hit ok button.
it working on simulator and goes to calling option, but when i check on device nothg happn. my device model is 9800.
String[] buttons = { "CALL" ,"CANCEL" };
Dialog dialog = new Dialog("Are you sure want to call "+number+" ?", buttons, null, 1, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION));
if (dialog.doModal() == 0)
{
try
{
String numbers = StringUtils.replaceAll(number, "-", "");
Phone.initiateCall(Phone.getLineIds()[0],numbers);
}
catch (RadioException e)
{
}
}
try this -
PhoneArguments callArgs = new PhoneArguments(PhoneArguments.ARG_CALL,numbers);
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, callArgs);

Coding4Fun MessagePrompt not displayed when app is on the splash screen

I am using coding4fun message prompt in my app to display message box with customized buttons to the user. It works fine when the app is in the foreground and there is a message to be displayed. But, When I exit the app and re-launch it there are a set of things happening when after app's splash screen is displayed and before the main screen of the app is shown. During this process the app checks if any upgrade is available, if there are upgrades then on the splash screen the message box must be displayed to the user. When i was previously using xna framework message box this worked well, but due to marketplace submission process I replaced xna framework message box with coding4fun message prompt and the message prompt doesn't show when splash screen is displayed. Is this how Coding4Fun message prompt works or am i doing something wrong?
here is how i have implemented the message prompt in my code..
public MainPage()
{
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
DataManager.getInstance().setUIListener(this);
if (checkUpgradeStatus())
{
return;
}
});
}
private bool checkUpgradeStatus()
{
try
{
string flag = "1";
if (!Utils.isNullString(flag))
{
DataManager.getInstance().CheckForUpgrade();
if (flag.Equals(CacheManager.MAJOR_UPGRADE))
{
customizedMessageBox(Utils.APP_UPGRADE_CONFIRM, CustomizedMessageBox.APP_UPGRADE_CONFIRM_TITLE, AppResources.APP_UPGRADE_CONFIRM);
DataManager.getInstance().UpdateBadge(true);
return true;
}
else if (flag.Equals(CacheManager.MINOR_UPGRADE))
{
CacheManager.getInstance().writeDataToConfigFile(CacheManager.APP_UPGRADE_STATUS, "0");
customizedMessageBox(Utils.APP_MINOR_UPGRADE_CONFIRM, CustomizedMessageBox.APP_MINOR_UPGRADE_CONFIRM_TITLE, AppResources.APP_UPGRADE_MINOR_CONFIRM);
DataManager.getInstance().UpdateBadge(true);
return false;
}
}
CacheManager.getInstance().writeDataToConfigFile(CacheManager.APP_UPGRADE_STATUS, "0");
return false;
}
catch (Exception ex)
{
Logger.log(TAG, ":checkUpgradeStatus():" + ex.Message);
return false;
}
}
public void customizedMessageBox(int messageboxtype, string title, string text)
{
try
{
switch (messageboxtype)
{
Case 6:
messageBox = new MessagePrompt();
Button btnMinorUpgrade = new Button();
btnMinorUpgrade.Content = "Upgrade";
messageBox.ActionPopUpButtons.Add(btnMinorUpgrade);
btnMinorUpgrade.Click += new RoutedEventHandler(btnMinorUpgrade_Click);
Button btnMinorUpgradeCancel = new Button();
btnMinorUpgradeCancel.Content = "Cancel";
messageBox.ActionPopUpButtons.Add(btnMinorUpgradeCancel);
btnMinorUpgradeCancel.Click += new RoutedEventHandler(btnMinorUpgradeCancel_Click);
messageBox.Show();
break;
}
}
catch (Exception ex)
{
Logger.log(TAG, ":customizedMessageBox():" + ex.Message);
}
}
NOTE*:- For testing purpose I have hard-coded flag's value to "1".
All the answers and suggestions appreciated.
Thank you

BlackBerry: Programmatic "Add to contacts"

If I type a phone number into the phone application on my Blackberry (5.0.0) I can hit the menu button, and one of the options is "Add to contacts" which will bring up the add contact screen, with the phone number already populated. I would like to do the same thing in my app - bring up the 'add to contacts' screen and pre-fill it with a particular phone number. Is this possible on the BlackBerry 5.0 OS?
While browsing for more information on BlackBerry contacts, I came across this support forum question, which answers my question indirectly. Posted here for anyone else in a similar situation:
http://supportforums.blackberry.com/t5/Java-Development/Problem-adding-contact-to-phone/m-p/341728/highlight/true#M62692
try
{
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] = "Kate";
name[Contact.NAME_FAMILY] = "Turner";
contact.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
AddressBookArguments entry = new AddressBookArguments(AddressBookArguments.ARG_NEW, contact);
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, entry);
}
catch (Throwable t)
{
}

Resources