I'm a flex developer and have a small problem.
I use XMLApllicationContext to load an XML file.
I load my context and then add the config location to it.
In this files I take care of creating an URL to connect to.So I made an eventlistner for my XMLApplicationContext with Event.COMPLETE so I know when he's done and he can connect.
No I'm a little bit dummytesting and if the user has given a wrong host and port the URL will not exist. So there will never be an Event.COMPLETE action.
For that I would love to know how I can solve this.
Now I have this code:
public function execute():*
{
m_context = new XMLApplicationContext("application-context.xml");
m_context.addConfigLocation("application-context-services.xml");
m_context.addEventListener(Event.COMPLETE, onComplete);
m_context.addEventListener(......);//need to know what has to come between the brackets
m_context.load();
ServiceLocator.getInstance().context = m_context;
}
I allready tried some things but haven't found a solution yet.
Thank you in advance.
Kind regards,
Thibault Heylen
Did you try the IOErrorEvent?
If that doesn't work for you, you could try creating a file reference and check if it exists ...
var f:File = new File("application-context.xml");
if (f.exists) {
//...
}
Im not quite sure, but if this is a local file you maybe have to add "app:/path/to/file/" in front of your url/file name
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.
My code used to work, it does not work anymore, I tried troubleshooting and can't figure out why.
I have this piece of code in my PHP:
$android_id_01 = $_GET['pmysql_room_id'];
$android_id_02 = "";
$f = fopen("00_android_id_01.txt", "w");
fwrite($f, print_r($android_id_01, true));
fclose($f);
$f = fopen("00_android_id_02.txt", "w");
fwrite($f, print_r($android_id_02, true));
fclose($f);
For troubleshooting I created two android IDs ($android_id_01 and $android_id_02) which are both empty (The first one is From Android and the second one I created directly from PHP).
Now when I launch my Android device, the PHP file is executed from server side and both the text files are created empty and identical. Now my code only works when I use $android_id_02 and not $android_id_01 from the code below:
if ($android_id == '')
{
//my code
}
(Yes when I use either one of the $android_id_01 OR $android_id_02 I rename it to $android_id and comment out the other one)
My question is, although this was working yesterday, why does it work with $android_id_02 = ""; and not $android_id_01 = $_GET['pmysql_room_id']; even though they are both empty????
I don't know what changed from yesterday to today.
Ok after a bit of troubleshooting I found a solution, strange though.
On the server side "display_errors" under PHP settings must be turned off. Somehow having this on interferes with the json_encode sent back to android client. (even though my code is not generating any errors)
I have built webrtc for android and have included the jar file in my project. I want to attach data channel to my PeerConnection object. On web, we do following in javascript :
sendChannel = pc.createDataChannel("sendDataChannel", {reliable: true});
or
sendChannel = pc.createDataChannel("sendDataChannel", {reliable: false});
where pc is the PeerConnection.
I want to do same in Java on Android using native webrtc code. I have little confusion. By looking at Jar file on eclipse, I could see that createDataChannel method of PeerConnection takes two arguments of type String and Init.
PeerConnection.createDataChannel(String, Init)
I could not understand what should I put in the second argument. WebRTC documentation, I found, is for web applications. I have seen the following WebRTC draft document but could not understand clearly.
http://www.w3.org/TR/webrtc/#methods-2
It would be helpful if someone can provide a small example of how it should be used.
Currently, I am trying to do this:
DataChannel dc = this.pc.createDataChannel("sendDataChannel", new DataChannel.Init());
You'd create the Init instance and manipulate the public properties before passing it to createDataChannel:
https://code.google.com/p/webrtc/source/browse/trunk/talk/app/webrtc/java/src/org/webrtc/DataChannel.java#35
If you did not find "reliable" there, that is because this does not work anymore. See maxRetransmits and maxRetransmitTimeMs.
Try to make a new Init and assign it a id if you want otherwise just pass new Init() in second argument it will work.
I am trying out odata4j in my android app to retrieve data from a DB that can be accessed from a WCF service.
ODataConsumer co = ODataConsumer.create("http://xxx.xx.xx.xxx:xxxx/Users");
for(OEntity user : co.getEntities("Users").execute())
{
// do stuff
}
However this crashes at the call to getEntities. I have tried a variety of other calls as well, such as
Enumerable<OEntity> eo = co.getEntities("Users").execute();
OEntity users = eo.elementAt(0);
However this also crashes at eo.elementAt(0).
The logcat doesn't tell me anything, and the callstack seems to be Suspended at ActivityThread.performLaunchActivity.
Entering "http://localhost:xxxx/Users" in my web browser on the other hand works as expected and returns the users in my DB in xml format.
Any ideas on how I can debug this?
To log all http requests/responses:
ODataConsumer.dump.all(true);
The uri passed to the consumer .create call should be the service root. e.g. .create("http://xxx.xx.xx.xxx:xxxx/"); Otherwise your code looks fine.
Note the Enumerable behaves like the .net type - enumeration is deferred until access. If you plan on indexing multiple times into the results, I'd suggest you call .toList() first.
Let me know what you find out.
Hope that helps,
- john
I guess the call should be:
ODataConsumer co = ODataConsumer.create("http://xxx.xx.xx.xxx:xxxx");
for(OEntity user : co.getEntities("Users").execute())
{
// do stuff
}
create defines service you want to connect but Users is the resource you want to query.
Can you try this way.
OEntity oEntity;
OQueryRequest<OEntity> oQueryRequest= oDataJerseyConsumer.getEntities(entityName);
List<OEntity> list= oQueryRequest.execute().toList();
for (OEntity o : list) {
List<OProperty<?>> props = o.getProperties();
for (OProperty<?> prop : props) {
System.out.println(prop.getValue().toString());
}
}
Is there anyone there who can tell me how i can send a string ("example") to an ipadress on a local network via wifi in as3 on air on adroid.
Thanks in advance!
FlashCreated
I'd imagine you can just use the HTTPService class or URLRequest (if you're not using Flex) the code would be something like this:
var urlRequest:URLRequest = new URLRequest("http://192.168.1.100/test.php");
var urlVariables:URLVariables = new URLVariables();
urlVariables.testVarName = "example";
urlRequest.data = urlVariables;
sendToUrl(urlRequest);
alternatively if you want to listen to the response use a URLLoader, if you're going with Flex HTTPService basically wraps up this functionality into a single class for that just create one set the url and call myHTTPService.send([optional params if not on data]);
Let me know if this doesn't work out and what errors you get or behavior, haven't actually tried yet within an Android device but if there's variance in the approach I'd like to know as well.
So php file is resident on the computer your sending the mesange to?