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)
{
}
Related
absolute beginner with xamarin.
Followed the following tutorial to try and simply click a button to display the contact list, select a contact, and then to display firstname, surname, and address on the screen.
https://github.com/xamarin/recipes/tree/master/Recipes/ios/shared_resources/contacts/choose_a_contact
Managed to get the firstname and surname to be displayed, but cannot get the address. Constantly getting the error
Foundation.MonoTouchException: Objective-C exception thrown. Name: CNPropertyNotFetchedException Reason: A property was not requested when contact was fetched.
On the
contanct.PostalAddresses
This is the snippet of code:-
partial void UIButton197_TouchUpInside(UIButton sender)
{
// Create a new picker
var picker = new CNContactPickerViewController();
// Select property to pick
picker.DisplayedPropertyKeys = new NSString[] { CNContactKey.GivenName, CNContactKey.FamilyName, CNContactKey.PostalAddresses };
// Respond to selection
var pickerDelegate = new ContactPickerDelegate();
picker.Delegate = pickerDelegate;
pickerDelegate.SelectionCanceled += () => {
SelectedContact1.Text = "";
};
pickerDelegate.ContactSelected += (contact) => {
SelectedContact1.Text = contact.GivenName;
SelectedContact2.Text = contact.FamilyName;
SelectedContact3.Text = contact.PostalAddresses
};
pickerDelegate.ContactPropertySelected += (property) => {
SelectedContact1.Text = property.Value.ToString();
};
// Display picker
PresentViewController(picker, true, null);
}
Am i missing something?
Seem to have resolved this if anyone else is having a similar issue.
The solution was to completely close down visual studio on the mac and re-open it.
Originally, i was stopping the project, and re-building. Possibly a bug, but non of my changes where being picked up.
A simple re-start kicked it back in
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);
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
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());
}
}
I have problem in finding the current opened application name.
I used ApplicationManager class for getting the visible applications.
The application descriptors are showing the same name for all these apps Email,Messaging,Sms,call log.
They are displaying "net_rim_bb_messaging_app" for all the above apps.
I need to find a unique identifier/name for these applications(Email,messaging,sms,calllog) when they are opened.
I tried this for the past 3 days and can't find a solution.
Can you please let me know a solution for this?
ApplicationDescriptor [] appDis = manager.getVisibleApplications();
int currentForgroundAppID = manager.getForegroundProcessId();
for(int i=0;i<appIDs.length;i++)
{
if(appDis[i].getModuleName().equals("net_rim_bb_messaging_app"))
{
//print Messaging app in foreground...
}
}
the case with in the for loop above is true for every app in this list.
Email,
Text message
Call log...
But, I need to find a unique way to find the application that was opened.
Thanks In Adv,
Satish.k
following code can display current foregroundApplication name
ApplicationDescriptor[] mAppDes;
ApplicationManager appMan = ApplicationManager.getApplicationManager();
appMan.getForegroundProcessId();
mAppDes = appMan.getVisibleApplications();
for (int i = 0; i < mAppDes.length; i++) {
boolean isFG = appMan.getProcessId(mAppDes[i]) == appMan.getForegroundProcessId();
if(isFG)
{
System.out.println("This is your Foteground application Name"+mAppDes[i].getName());
}else{
System.out.println("This is your Background application Name"+mAppDes[i].getName());
}
}