initiateCall option not working on blackberry device - blackberry

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

Related

How to show the 1st fragment when back button is pressed?

I'm new to Mobile Development
I am currently developing a Telephone Directory app from Xamarin Android, in this app, I have 4 Fragment(HomeFragment, AboutFragment, DirectoryFragment, and SyncFragment).
HomeFragment is the first fragment that shows from the app. When I click the item About in the side bar then pressed the back button, it works well because i used AddToBackStack(null) before commit() in the main activity.
But the problem is, let's say I open the app then it shows the HomeFragment fist by default, when i navigate to the AboutFragment, it shows the AboutPage, then if I navigate to the DirectoryFragment next and click the back button, i keep on going back to the AboutPage/AboutFragment, which is what i want to achieve is, it should go back to the HomePage/HomeFragment
In short, what i want to achieve is like the Navigation behavior of the Gmail App.
Anyway this is my code in Main Activity
switch (e.MenuItem.ItemId)
{
case (Resource.Id.nav_home):
FragmentTransaction ft = FragmentManager.BeginTransaction();
HomeFragment home = new HomeFragment();
ft.Replace(Resource.Id.HomeFrameLayout, home);
HideSoftKeyboard();
mDrawerLayout.AddDrawerListener(mDrawerToggle);
ft.AddToBackStack(null);
ft.Commit();
break;
case (Resource.Id.nav_about):
FragmentTransaction ft1 = FragmentManager.BeginTransaction();
AboutFragment about = new AboutFragment();
ft1.Replace(Resource.Id.HomeFrameLayout, about);
HideSoftKeyboard();
ft1.AddToBackStack(null);
ft1.Commit();
break;
case (Resource.Id.nav_etel):
FragmentTransaction ft2 = FragmentManager.BeginTransaction();
GHQFragment ghq = new DirectoryFragment();
ft2.Replace(Resource.Id.HomeFrameLayout, ghq);
HideSoftKeyboard();
ft2.AddToBackStack(null);
ft2.Commit();
break;
case (Resource.Id.nav_refresh):
if (CrossConnectivity.Current.IsConnected)
{
FragmentTransaction ft3 = FragmentManager.BeginTransaction();
SyncFragment sync = new SyncFragment();
ft3.Replace(Resource.Id.HomeFrameLayout, sync);
HideSoftKeyboard();
ft3.AddToBackStack(null);
ft3.Commit();
}
else
{
Toast.MakeText(this, "Please connect to the internet to sync records.", ToastLength.Long).Show();
}
break;
You can override the OnKeyDown method like following code.
public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back)
{
FragmentManager fragmentManager = this.FragmentManager;
int count = fragmentManager.BackStackEntryCount;
for (int i = 0; i < count; ++i)
{
fragmentManager.PopBackStack();
}
// your code
return false;
}
return base.OnKeyDown(keyCode, e);
}
I switch three fragment, when I click the back button. it switch to the first fragment.
Update
Do you want to achieve the result that you click back button then back to the desktop when you in the HomePage?
Here is code.
public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back)
{
FragmentManager fragmentManager = this.FragmentManager;
int count = fragmentManager.BackStackEntryCount;
if(count>0){
for (int i = 0; i < count; ++i)
{
fragmentManager.PopBackStack();
}
return false;
}
}
return base.OnKeyDown(keyCode, e);
}

SWT: Integrate clickable link into StyledText

With the help of this question I was able to figure out how I can display a link inside a StyledText widget in SwT. The color is correct and even the cursor changes shape when hovering over the link.
So far so good, but the link is not actually clickable. Although the cursor changes its shape, nothing happens if clicking on the link. Therefore I am asking how I can make clicking the link to actually open it in the browser.
I thought of using a MouseListener, tracking the click-location back to the respective text the click has been performed on and then deciding whether to open the link or not. However that seems way too complicated given that there already is some routine going on for changing the cursor accordingly. I believe that there is some easy way to do this (and assuring that the clicking-behavior is actually consistent to when the cursor changes its shape).
Does anyone have any suggestions?
Here's an MWE demonstrating what I have done so far:
public static void main(String[] args) throws MalformedURLException {
final URL testURL = new URL("https://stackoverflow.com/questions/1494337/can-html-style-links-be-added-to-swt-styledtext");
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, true));
StyledText sTextWidget = new StyledText(shell, SWT.READ_ONLY);
final String firstPart = "Some text before ";
String msg = firstPart + testURL.toString() + " some text after";
sTextWidget.setText(msg);
sTextWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
StyleRange linkStyleRange = new StyleRange(firstPart.length(), testURL.toString().length(), null, null);
linkStyleRange.underline = true;
linkStyleRange.underlineStyle = SWT.UNDERLINE_LINK;
linkStyleRange.data = testURL.toString();
sTextWidget.setStyleRange(linkStyleRange);
shell.open();
while(!shell.isDisposed()) {
display.readAndDispatch();
}
}
Okay I was being a little too fast on posting this question... There's a snippet that deals with exactly this problem and it shows, that one indeed has to use an extra MouseListener in order to get things working.
The snippet can be found here and this is the relevant part setting up the listener:
styledText.addListener(SWT.MouseDown, event -> {
// It is up to the application to determine when and how a link should be activated.
// In this snippet links are activated on mouse down when the control key is held down
if ((event.stateMask & SWT.MOD1) != 0) {
int offset = styledText.getOffsetAtLocation(new Point (event.x, event.y));
if (offset != -1) {
StyleRange style1 = null;
try {
style1 = styledText.getStyleRangeAtOffset(offset);
} catch (IllegalArgumentException e) {
// no character under event.x, event.y
}
if (style1 != null && style1.underline && style1.underlineStyle == SWT.UNDERLINE_LINK) {
System.out.println("Click on a Link");
}
}
}
});

Why Facebook profile picture request return null on iOS?

Everything works perfect on android but when I try to get the profile picture on iOS devices. The image returns null. I checked the Facebook documentation for iOS 9 I have exactly the same plist as shown in documentation. When I run the app in console I see "FB is log in" message but the profile pic has not shown. Can anyone help?
void Awake()
{
instance = this;
FB.Init(SetInıt, OnHideUnity);
}
public void FbLogin()
{
// This is an event trigger when the button pressed.
List<string> permissions = new List<string>();
permissions.Add("public_profile");
FB.LogInWithReadPermissions(permissions, AuthcallBack);
}
void DealWithFbMenus(bool isLoggedIn)
{
// This function is called in SetInit func in Awake.
if(isLoggedIn)
{
fbButton.SetActive(false);
profilePicture.gameObject.SetActive(true);
loggedInPlayer = true;
//FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUserName);
FB.API("/me/picture?type=square&height=128&width=128", HttpMethod.GET, DisplayProfilePic);
}
else
fbButton.SetActive(true);
}
void DisplayProfilePic(IGraphResult result)
{
if(result.Texture != null)
{
profilePicture.sprite = Sprite.Create(result.Texture, new Rect(0,0, 128, 128), new Vector2());
}
}
It is a bug on Unity 5.2. It fixed on new version of Unity 5.3

Monotouch : pause application unit dialog response

How can i pause application for prevention from running next method unit client does not selected dialog buttons?
For example i am showing location update dialog for accessing location service and i want to pause my application for dialog response
public CLLocation UpdateUserLocation()
{
CLLocation currentLocation = null;
CLLocationManager LocMgr = new CLLocationManager();
if (CLLocationManager.LocationServicesEnabled)
{
if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0))
{
LocMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
{
currentLocation = e.Locations [e.Locations.Length - 1];
};
}
else
{
LocMgr.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) =>
{
currentLocation = e.NewLocation;
};
}
LocMgr.StartUpdatingLocation ();
LocMgr.Failed += (object sender, NSErrorEventArgs e) =>
{
Console.WriteLine (e.Error);
};
}
else
{
currentLocation = null;
Console.WriteLine ("Location services not enabled, please enable this in your Settings");
}
if (currentLocation != null)
{
LocationDetector.Instance.UpdateCurrentArea (new MyLatLng (currentLocation.Coordinate.Latitude, currentLocation.Coordinate.Longitude));
}
return currentLocation;
}
If I am understanding your question correctly.
When you display a dialog box, you are wanting to stop execution of the current method from further executing until the user selects a dialog box response.
Once they have selected a response, you would then like to continue execution of the code in the same function, effectively achieving your 'pause' that you are after.
To achieve this in iOS you can use a TaskCompletionSource.
In the example below it shows a dialog box first, asking the user if they want some coffee and then waits for the user to respond.
Once the user responds, it then continues execution, within the same function, and displays a further message box that is dependent on the selection that the user made.
UIButton objButton1 = new UIButton (UIButtonType.RoundedRect);
objButton1.SetTitle ("Click Me", UIControlState.Normal);
objButton1.TouchUpInside += (async (o2, e2) => {
int intCoffeeDispenserResponse = await ShowCoffeeDispenserDialogBox();
//
switch (intCoffeeDispenserResponse)
{
case 0:
UIAlertView objUIAlertView1 = new UIAlertView();
objUIAlertView1.Title = "Coffee Dispenser";
objUIAlertView1.Message = "I hope you enjoy the coffee.";
objUIAlertView1.AddButton("OK");
objUIAlertView1.Show();
break;
case 1:
UIAlertView objUIAlertView2 = new UIAlertView();
objUIAlertView2.Title = "Coffee Dispenser";
objUIAlertView2.Message = "OK - Please come back later when you do.";
objUIAlertView2.AddButton("OK");
objUIAlertView2.Show();
break;
}
});
//
View = objButton1;
private Task<int> ShowCoffeeDispenserDialogBox()
{
TaskCompletionSource<int> objTaskCompletionSource1 = new TaskCompletionSource<int> ();
//
UIAlertView objUIAlertView1 = new UIAlertView();
objUIAlertView1.Title = "Coffee Dispenser";
objUIAlertView1.Message = "Do you want some coffee?";
objUIAlertView1.AddButton("Yes");
objUIAlertView1.AddButton("No");
//
objUIAlertView1.Clicked += ((o2, e2) => {
objTaskCompletionSource1.SetResult(e2.ButtonIndex);
});
//
objUIAlertView1.Show();
//
return objTaskCompletionSource1.Task;
}

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

Resources