I'm trying to get my game working on Android. I've ported it with the free version of Apportable and it works quite well, but I haven't been able to implement the gyroscope feature.
CMMotionManager gets initialized but the motion updates never start (or at least handleDeviceMotion: never gets called). The motion manager's isAccelerometerActive property is always NO, but isAccelerometerAvailable is YES.
Using [NSOperationQueue mainQueue] doesn't help either.
This is how I initialize the motion manager:
self.motionManager = [[CMMotionManager alloc] init];
self.motionManager.gyroUpdateInterval = .2;
[self.motionManager startDeviceMotionUpdatesToQueue:[[NSOperationQueue alloc] init]
withHandler:^(CMDeviceMotion *motion, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self handleDeviceMotion:motion];
});
}];
It produces the following message to logcat:
E/Sensors ( 507): HAL:ERR open file /sys/bus/iio/devices/iio:device0/dmp_event_int_on to write with error 2
E/Sensors ( 507): HAL:ERR can't disable DMP event interrupt
I have no idea what this means...
I'm testing the app on Asus Nexus 7.
Is there something special I need to do to use CoreMotion with Apportable?
Edit:
Here's a simple test project I created to demonstrate the issue.
CoreMotion should work with apportable. Here is a simplified initialization and usage paradigm that I've tested on a Nexus 7 (2012).
self.motionManager = [[CMMotionManager alloc] init];
[self.motionManager startDeviceMotionUpdates];
self.motionTimer = [NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:#selector(handleDeviceMotion)
userInfo:nil
repeats:YES];
Instead of using startDeviceMotionUpdatesToQueue: withHandler: to process the motion events, try explicitly accessing the deviceMotion property in a handleDeviceMotion method which will be called by the repeating timer.
-(void) handleDeviceMotion {
CMDeviceMotion *motion = [self.motionManager deviceMotion];
// use motion data accordingly
}
And don't forget to stop updates when you're done!
[self.motionManager stopDeviceMotionUpdates];
For this sort of device motion in particular, we had a fairly layered series of issues that I've (hopefully) resolved with the next SDK update. I've implemented yaw, pitch, and roll, and they seem to give relatively sane values. If you're still having issues, email sdk(#)apportable.com (delete the parens obviously) and mention me.
Related
I'm working on Ionic mobile app development.
My requirement is to create client side logger to track issues in app. I used the methods mentioned in https://github.com/pbakondy/filelogger, and I could able to create the log file in both Android and iOS.
For the first time when I open the app, it creates the log file in cordova.file.dataDirectory, when I close and reopen the app in i*OS, I'm trying to read the content of the file which was created using the below
$fileLogger.getLogfile().then(function (loggerContent) {
var temp =loggerContent;
});
But the application says
{
"applicationDirectory":null,
"applicationStorageDirectory":null,
"dataDirectory":null,
"cacheDirectory":null,
"externalApplicationStorageDirectory":null,
"externalDataDirectory":null,
"externalCacheDirectory":null,
"externalRootDirectory":null,
"tempDirectory":null,
"syncedDataDirectory":null,
"documentsDirectory":null,
"sharedDirectory":null
}
So I couldn't able to find the file where i saved my logs.
Please help me resolve this issue or if you could recommend me a different method to get around this issue, that would be great!
Thanks for the answers
There is a check list here and should solve your problem :
1-Be sure that the cordova-file-plugin is installed and works in your test environment.
2-Be sure that the cordova.js file is refrenced by your html and before your code usage.
3-Be sure to call your codes after device_ready state :
check this
4-Call your function after a short delay (use setTimeOut in Javascirpt)
Ali's item 4 is very important:
I had a similiar problem on different platforms: cordova.file.dataDirectory was null.
I tracked cordova.file.dataDirectory over the lifecycle and it was first accessed by my Ionic 2 code BEFORE the device ready event was fired.
My "mistake": I wanted to load data during the constructor(!) of a service. Seems too early.
I'm having a confusing problem. I'm trying to make a Web cleint that uses WSDL.
I'm using C++ RAD Studio 10 Seattle, but the same problem occured in RAD Studio XE8(older version).
1.I create a Multi-Device Application, add one Edit component and one Button.
2.I create a WSDL Importer by changing the location of the WSDL file to : "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL" and leave all other setting to default.
3.On ButtonClick event of the button I write two lines of code :
_di_TempConvertSoap Converter = GetTempConvertSoap(true,
"http://www.w3schools.com/webservices/tempconvert.asmx?WSDL");
Edit1->Text = Converter->CelsiusToFahrenheit("32");
So after these three steps I have one unit, which is the main Unit with the Form and with the button event. And one file "tempconvert.cpp" that the WSDL Importer has generated. It quite actually just translates the WSDL code to a C++ one and defines the method to communicate with the server. In my case I have two methods : FahrenheitToCelsius() and CelsiusToFahrenheit(), in the example I use CelsiusToFahrenheit().
I compile it to 32-bit Windows platform, run it and when I click the button, the result "89.6" appears in the text of the Edit component. So this is working as expected.
But when I change the target platform to "Android" and use my mobile phone "Samsung GT-I8262" with Android 4.1.2 and run the project, it just stops and exits. I debugged the problem and it stops at the first command in "tempconvert.cpp" in RegTypes() method.
// ************************************************************************
//
// This routine registers the interfaces and types exposed by the WebService.
// ************************************************************************ //
static void RegTypes()
{
/* TempConvertSoap */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/%operationName%");
InvRegistry()->RegisterInvokeOptions(__delphirtti(TempConvertSoap), ioDocument);
/* TempConvertSoap.FahrenheitToCelsius */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "FahrenheitToCelsius", "",
"[ReturnName='FahrenheitToCelsiusResult']", IS_OPTN);
/* TempConvertSoap.CelsiusToFahrenheit */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "CelsiusToFahrenheit", "",
"[ReturnName='CelsiusToFahrenheitResult']", IS_OPTN);
/* TempConvertHttpPost */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertHttpPost), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertHttpPost), L"");
}
#pragma startup RegTypes 32
Does someone have any idea why this might be happening? I tried on two other Samsung phones and it didn't work. The error that shuts the program down is "Segmentation fault(11)", and more precisely it stops at the following line of code in "System.pas" file :
u_strFromUTF8(PUChar(Dest), MaxDestChars, DestLen, MarshaledAString(Source), SourceBytes, ErrorConv);
Here is some info that I've found about the function:
u_strFromUTF8 - function that converts a UTF-8 string to UTF-16.
UCHAR is a Byte(in Delphi), so PUCHAR is a pointer to Byte.
I cannot se what could possibly go wrong with this function which apparently only converts a string.
So my question is why does the project work on Windows 32 bit version, but on Android it throws Segmentation fault(11)?
I hope I could find a solution for this problem. I will keep looking.
Thank you,
Zdravko Donev :)
UPDATE:
I disassembled the line:
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-16");
to get :
TInvokableClassRegistry *Class = InvRegistry();
TTypeInfo *Info = __delphirtti(TempConvertSoap);
UnicodeString Namespace = "http://www.w3schools.com/webservices/";
UnicodeString WSDLEncoding = "utf-8";
Class->RegisterInterface(Info, Namespace, WSDLEncoding);
And I saw that the problem occurs when calling InvRegistry() function, but I still haven't found the problem as I cannot reach the source code of the function.
I found a solution.
I deleted the line
#pragma startup RegTypes 32
and called the method RegTypes() on my own when I create the form and it worked.
I want to access a android device from python to download some photos.
libmtp works from the CLI.
Than pymtp. It's been around for a while but it's designed for python 2 and i'm using python 3. Meanwhile fixed several minor issues but i'm stuck at an error from function get_filelisting
specially this section:
ret = []
next = files
while next:
ret.append(next.contents)
if (next(next.contents) is None):
break
next = next(next.contents)
The error is related to the "next".
That section looks strange to me, i've been coding in python for a while but i'm new to ctypes. Tried a lot of variants, they all failed. The "next" could be confusing with python buildin function so i renamed it to nextpointer and came to this code:
ret = []
nextpointer = files
while nextpointer:
ret.append(nextpointer.contents)
nextpointer = nextpointer.contents.next
It seems to work but did it work by accident ? does it have any design flaws ? Could anyone with experience on python ctypes confirm this a solution ? Any suggestion welcome.
From python2.7 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its next() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
from python3 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
Notice that next() method was removed from python3 but the function still exists.
This is all I can say about the next function and .next()/__next__() methods.
I downloaded the pymtp module and get_filelisting() is slightly different from what you posted in your ported code, here it is:
ret = []
next = files
while next:
ret.append(next.contents)
if (next.contents.next == None):
break
next = next.contents.next
If none of this helped you (which probably didn't :D), the version of pymtp library that I am using is 0.0.6 download using pip.
I am new to Appium and have been trying to automate the Conversion Calculator app for Android. Am getting the error "org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters", when trying to find a EditText element. Using Appium ver 1.0.0 and Android 4.3
The following is my code:
List<WebElement> textViews = driver.findElements(By.className("android.widget.TextView"));
for (i=0; i<textViews.size(); i++) {
if(textViews.get(i).getText().toLowerCase().contains("memory")) {
textViews.get(i).click();
}
}
Thread.sleep(5000);
WebElement editText = driver.findElement(By.className("android.widget.EditText"));
editText.sendKeys("123");
Even findElement by ID is not working. Please let me know what I am doing wrong here or if I need to provide more details.
I would use
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); instead of Thread.sleep(5000).
Try to use a newer version of Appium, I's been improved a lot. You can download the latest version of Appium and Appium clients here:http://appium.io/downloads.html
But be careful because in the newer version the findElement throws an Exception if there are more then one result of the search.
I would write this in a comment but I've not enough reputation :/
Possible Cause:
Multiple EditText in the current screen.
Please try with the following:
Solution1:
List<WebElement> editText = driver.findElements(By.className("android.widget.EditText"));
editText.get(0).sendKeys("123");
0 - Index of EditText
Solution2:
Use any other locating strategy like Xpath.
Maybe you could try waiting until the element is visible or enabled using a WebDriverWait object?
Avoid using sleep as much as possible, try using the WAIT command.
Sleep without waiting for the time that has been determined, even if the element is already on the screen.
In the case of the wait command, as soon as the element appears, the action will already be performed, this along the code will reduce the execution time considerably.
The issue for me was the app path I was using. If you are using a config file make sure to declare the application separately from the device.
If not, make sure the "app" capability has the right path. Here is the code in my config file for example:
devices_by_ids = {
"platformName": "Android",
"appium:DEVICE ADB ID": {
"android_version": "13",
"device_name": "google_Pixel_5a",
"DEVICE ADB ID": "DEVICE ADB ID",
"port":"4723",
"autoGrantPermissions": "true",
},
"appium:app": "YOUR APP PATH",
"appium:appWaitActivity": "*"
}
In Appium v2 use
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
I'm working off Livecode v5.5.4 on the Android platform... I've been able to successfully publish apps, however, can not figure out how to install inneractive ads... As LC has partnered with inneractive they provide direction which suggests its as easy as...
mobileAdRegister "YOUR-AD-KEY" //I've replaced with my APP ID from inneractive
local tDetails
put "30" into tDetails["refresh"] // The advert refresh interval in seconds
put 25 into tDetails["age"] // The age of the target audience
put "male" into tDetails["gender"] // The expected gender of the target audience
mobileAdCreate "myAd1", "banner", (0,0), tDetails
however, nothing seems to work... any LC ppl out there with advice??... thanks
If there's no error reported from Mark's suggestion you might want to ensure it's visible with:
mobileAddSetVisible "myAd1",true
Failing that could you post the result of the mobileAds function and let us know if the adLoaded or adLoadFailed message is being sent to the object that executed mobileAdCreate?
You need to check the value of the result:
mobileAdCreate "myAd1","banner",(0,0),tDetails
put the result into rslt
if rslt is not empty then
beep
answer error rslt
end if
Kind regards,
Mark