Program not working in my lower version mobile - blackberry

I wrote a code to get the location coordinates using cellsite based location and here is the code i used:
Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
try {
LocationProvider lp=LocationProvider.getInstance(criteria);
if(lp !=null)
{
Location loc=null;
loc=lp.getLocation(-1);
if(loc!=null)
add(new EditField(loc.getQualifiedCoordinates().getLatitude()+"\n"+loc.getQualifiedCoordinates().getLongitude(),""));
else
add(new EditField("no location found",""));
}
else
{
add(new EditField("unable to find the location provider", ""));
}
} catch (LocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I used Blackberry 8520 mobile with airtel sim card with version 5.0 and it worked perfectly. I got the coordinates and it is fine. Now i used the same application with same sim card with Blackberry 8520 version 4.6.1. When i start the application, it is starting but it is not displaying even the main screen. This is the output when i run the app in 5.0 mobile:
and when i run this in 4.6 i didn't get any screen atleast showing error message. Please provide a solution. Thank you. To clarify further i installed google maps on 4.6 mobile with the same sim card and it showed me the correct location and also there is also no problem in accessing the internet

Did you compile the app against a version 5 compiler? If yes then your app wont start in os4.6 device. You have to compile in atleast 4.6 jde compiler to get your app working.

Related

Java client PressKey Method works fine, but the key is not pressed in Mobile?

I have this below snippet of code in my automation framework
public void settings() {
try {
//((AndroidDriver) Driver).pressKeyCode(AndroidKeyCode.SETTINGS);
((AndroidDriver) Driver).pressKey(new KeyEvent(AndroidKey.SETTINGS));
updateTestLog(Action, "settings pressed", Status.PASS);
} catch (Exception ex) {
updateTestLog(Action, ex.getMessage(), Status.DEBUG);
Logger.getLogger(KeyActions.class.getName()).log(Level.SEVERE, null, ex);
}
}
I have connected with the mobile and see if it's working fine. In Appium server got log traces that Key code 176 (Settings) worked fine. But no action in mobile screen
I have tried it for different keys like "Menu","home","search" and "enter". I see it is executed and working fine in mobile.
If you need to open Settings Menu I believe the best option would be calling driver.startActivity() function like:
((AndroidDriver) driver).startActivity(new io.appium.java_client.android.Activity("com.android.settings",".Settings"));
If you're looking for a cross-platform solution it might be easier to go for Launch command available via SeeTest Appium Extension

Using StorageService in Gluon to analyze how much memory storage is possible - And getting strange result

I have used com.gluonhq.charm.down.plugins.StorageService to look for how much it would be possible to store with a application on windows, mac, iOS and Android seperate devices. I get a strange result on iOS (the rest is as you can expect with windows, mac and Android) - and need help to understand why that is.
According to the StorageSevice I have 5363227164672 (bytes) on my iPhone 6. How is that possible/why such strange result? That is 5365 GB!
File privateStorage = null;
try {
privateStorage = Services.get(StorageService.class).flatMap(StorageService::getPrivateStorage).orElseThrow(() -> new FileNotFoundException("Could not access prrivate storage"));
} catch (FileNotFoundException ex) {
Logger.getLogger(Go.class.getName()).log(Level.SEVERE, null, ex);
}
// a simple print to javafx textArea method:
out("size is " + privateStorage.getFreeSpace());
Here is the documentation for StorageService.
Edit:
With .getUsableSpace() I get 179GB on iPhone6 which is not correct. Using .getUsableSpace() on windows gave the same result as before, (Android and Mac not rechecked with getUsableSpace().

Testing React Native with Appium: how to get past "Permit drawing over other apps"?

In my initial proof of concept for testing a React Native mobile app using Appium, I noticed that when I load the APK to start my test, I am presented with an Android prompt to "Permit drawing over other apps" as I am creating my AndroidDriver driver. If I move the slider manually, then click the back button, all is good -- the app loads fully, and my test proceeds. However, I don't see how to do this with automation using my Appium script because it looks like the driver instantiation will not complete until the slider is moved.
Most people don't see this in Appium testing as it appears to be specific to React Native in dev mode, as seen here...
Here's my code where I've put in conditional code to click the slider, but I never get there because it waits at the "driver = ..." line:
AndroidDriver driver = null;
#Before
public void setUp() throws Exception {
// < defining capabilities (emulator6p) up here...>
// initialize driver object
try {
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), emulator6p);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
#Test
public void test1() throws Exception {
By BY_slider_permitDrawing = By.id("android:id/switchWidget");
boolean present = (driver.findElements(BY_slider_permitDrawing).size() == 1);
if (present) {
driver.findElement(BY_slider_permitDrawing).click();
driver.navigate().back();
}
WebElement button_begin = driver.findElementByAccessibilityId("button-lets-begin");
button_begin.click();
}
I definitely hear plenty of people say that Appium is a viable solution for React Native testing, and really need to get over this hump.
Thanks in advance for any suggestions!
jph
p.s. In case it wasn't really clear, the test does NOT hang at the "driver = " line if I am not loading the APK from scratch, but I will need to do that for CI testing in the future.
Setting right capabilities helped me to run Appium tests in Debug mode on Android:
{
...
"appWaitPackage": "com.android.settings, com.yourPackage",
"appWaitActivity": "com.android.settings.Settings$AppDrawOverlaySettingsActivity, com.yourPackage.MainActivity",
}
Replace yourPackage with your real package name used in Android app. Some docs here: https://appium.io/docs/en/writing-running-appium/caps/#android-only

How to locate element in UIautomator if native keyboard come before your application?

As per project requirement i am working on Mobile App automation. Not problem arises when i executed same code which worked fine on emulator but when it comes to real device the same code were getting failed.the problem is UiAutomator is not able to locate element because of native keyboard come before an application during simulation. I executed this entire thing into Galaxy nexus which works on ANDROID API 18.hence no point to execute whole automation suites in Selendroid mode. in below code after filling value in first editbox,control should have reached to second editbox to fill value and so on. But it does not fill value there because native keyboard appear before application.
SwipeableWebDriver driver = new SwipeableWebDriver(
new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
List<WebElement> editTextList = driver.findElements(By
.className("android.widget.EditText"));
editTextList.get(0).sendKeys(c + "Bob");
editTextList.get(1).sendKeys("123");
editTextList.get(2).sendKeys("456");
el = driver.findElement(By.className("android.widget.Button"));
el.click();
Please anyone who have idea to resolve this issue?
Thanks in advance.
Priyank Shah
First of all you should realize whether the soft keyboard is active or not - Use the following command from your code to check "mInputShown" parameter - If "true" - Active Soft Keyboard.
adb shell dumpsys input_method | grep mInputShown
Use this code for hiding the native keyboard in Java-appium running older versions of appium.
driver.navigate().back()
P.S - The adb command is useless for emulators as the flag whose value is being checked is always set to true, whether your keyboard is active or not.
I don't think you can, and and it is not a appium limitation.
From what I observed even the UIAutomator can not find the elements hidden by the keyboard.
I know 2 solutions for this:
Dismiss the keyboard. (I didn't find any elegant ways of doing that so I'm not using this.
Swipe/scroll on the view until the element is exposed, and then you can action it. This works fine for me.
you should be able to dismiss the keyboard by sending
driver.findElement(By.name("Return")).click();
adding new line character works too
editTextList.get(2).sendKeys("456\n");
If you can detect that the keyboard is open, I would suggest calling UiDevice.pressBack() to dismiss the keyboard.
You could be able to dismiss the keyboard by using the following code
driver.hideKeyboard();
Put the following two lines:
driver.getKeyboard();
driver.hideKeyboard();
Here is a uiautomator ready fully functional method that will respond with true if the keyboard is Open and false if it is closed:
public static boolean isKeyboardDisplayed() {
String checkKeyboardCommand = "dumpsys input_method | grep mInputShown";
try {
Process process = Runtime.getRuntime().exec(checkKeyboardCommand);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
process.waitFor();
if (output.toString().contains("mInputShown=true")) {
return true;
} else {
return false;
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
You may need to enable unicodeKeyboard: true in your android capabilities and use the keyboard button Return to hide the keyboard if shown (this work for me on iOS and Android)
For example, I am using ruby:
element = $appium.find_element(id: field_id)
element.clear
element.send_keys(data)
element.send_keys(:return) if driver.is_keyboard_shown

Capture pictues in blackberry application using VideoControl only works on emulator and not device

This is only some of the code because other parts of it are spread out but on the simulator for blackberry curve this adds a VideoControl to the manager and shows up fine with another button that actually captures the picture. However, when I run this on an actual Blackberry curve (version 6 I think) it doesn't display this on the screen.
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
_p.realize();
_videoControl = (VideoControl) _p.getControl("VideoControl");
if (_videoControl != null)
{
videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// _videoControl.setDisplayFullScreen(true);
_videoControl.setVisible(true);
// EnhancedFocusControl efc = (EnhancedFocusControl)p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
// efc.startAutoFocus();
_p.start();
if(videoField != null)
{
add(videoField);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
In my experience the way of image taking you use has appeared very unreliable (it worked fine only on a limited number of devices), so I stopped using it. Use native Camera app instead - it works fine on all devices.
A lot of the time when things work on the emulator but not device it's permissions related, have you checked ApplicationPermissionsManager?
Word of warning, from OS4.5 to 6 a lot of stuff has been deprecated so be sure you check you have the right permissions for the models you are working with.
e.g. ApplicationPermissions.PERMISSION_SCREEN_CAPTURE was deprecated in 4.6 I think.

Resources