I have a simple piece of code:
ParseObject testobject = new ParseObject("Test");
testobject.put("customerName", "John");
testobject.saveInBackground();
If I run this on my emulator, it works, a Test class is made in my Parse project and the value John is added to the Row customername.
If I run this on my mobile phone the result is also succesful.
But if I run the exact same program on my Tablet, nothing happens.
(the callback = null, .getResult() and .getError() are also null)
Any idea where the problem lies?
Are you using Wi-fi on your phone or using mobile internet? Depending on where you are (Home, School/University) they may have blocked some ports which stop the service from running.
Something I saw is, you've got spaces between 'testobject .put' and 'testobject .saveInBackground();', that may be your issue?
Related
In my Android app, I do poll a device (Wallbox) every 5 seconds using the Volley library. For one customer, I get
java.net.NoRouteToHostException: Address not available
after several hours. Usually, using the exactly same type of device and at my place, this polling works for days, but not at (at least) this customer.
The device address is on the local LAN.
I have not found any description about "address not available" that might apply to my case, or at least I did not see the point.
The call is always the same:
http://192.168.160.152/api/status
As this is live data, I set ".setShouldCache(false)" for the request.
Meanwhile, other HTTP requests (in this case, a query to a WWW address, also polled continuously), even using Volley, continue to work:
https://backend.powerfox.energy/api/2.0/my/***********/current
The connection works again after rebooting the device (and at the same original IP address), so I guess it has nothing to do with the wallbox or the router.
And if the wallbox would be not available, I assue I would get "unreachable" error or such.
Is there someone who can help me, what could cause that exception ("address not available"), and what can I do about it?
I'm fairly new to python SL4A and I could not find a question that helped me, so bear with me.
Here is what I'm working with so far:
import sl4a
UUID = ''
droid = sl4a.Android()
droid.toggleBluetoothState(True, False)
droid.bluetoothConnect(UUID)
print(droid.bluetoothGetConnectedDeviceName())
Here is the error that I get when I run the above code:
"java.io.IOException: Bluetooth not ready for this connID."
If I run the above code without the last line, I can see on my laptop that it's connected, but I want to see from the android's side that I can return the device name (for shits n' gigs).
What am I doing incorrectly so that I can get the android to return the device's name?
Edit: Please let me know if I should ask in a different manner; this is my first post, but I regularly troll this website for answers when I come to a roadblock.
I have implemented a receiver within my app that continually searches using Bluetooth and updates the server every 10 seconds with the available devices. One piece of information it returns is the RSSI value of the device. The code I use to get this value is:
node.Rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
So this seemed to work fine at first, using my test phone (Galaxy S4) I got expected values such as -75 or -88. However I have now tried a different phone shown in the link below:
http://www.amazon.co.uk/Waterproof-smartphone-Dustproof-Shockproof-Capacitive/dp/B00EZNSUPU/ref=pd_sim_sbs_ce_3?ie=UTF8&refRID=0YYHYTW6J2AVZK7DJJDJ
(Sorry if I'm not allowed to post this here, I'm not 100% on the rules, if there's a problem I'll happily remove it)
When using this phone with the same build of my app, the values for the RSSI range from 150-200.
Does anyone have any idea why this might be happening? Another problem I'm having with the phone is that when Bluetooth is on my Wi-Fi connection will eventually disappear, again this doesn't happen with my Galaxy S4. Is this test phone really that bad? Or am I missing something..
I'm developing an Android App which i want to communicate with a device connected via USB. This device is delivering data all the time. These data are visible with a programm on the android linux shell.
My goal is to see those data in my App and after that deliver them via a Service to other Apps.
So my question is: Can i "open" a connection from my Android App to the USB-Port so im continuesly receiveing the data in my app, which are sent by the usb-device? And if yes, how would the code look like?
*Edit
Thank you for your answers, the app itself doesn't run on the commandline any more. So its no executable anymore but a shared library getting load by my android app.
It did before, but i want to be able to initiate the connection using NDK methods in my App to be able to see the data in my App itself. So I've tried to see if a connection is allready open.
I've added some functions to my code, so i can see if the usb-connection is open and i have the permission to that usb device.
UsbManager.hasPermission(device)
returns true, because I'm using an itent filter.
UsbManager.openDevice(device)
returns an UsbDeviceConnection, so i seem to have the access to use that device.
What im not capable of so far is receiving either iniciating the bus connection to by usb-device and of course either getting data input of that device.
Since my native code allready has a while(true)-method which is only using callbacks to send data to my app when actually data getting sent trough my usb-device i want to keep the work done in my c-code.
The only job my app should do is open the bus-connection once and after that be ready for callback from the c-code.
Is that possible?
If you have the app that runs on the command line, you can actually run a command line from within your app. Take a look at the Process class and the ProcessBuilder docs for full details. The example given is below
To run /system/bin/ping to ping android.com:
Process process = new ProcessBuilder()
.command("/system/bin/ping", "android.com")
.redirectErrorStream(true)
.start();
try {
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
readStream(in);
finally {
process.destroy();
}
}
This is my first post so my apologies in advance if this is the wrong site to post this particular question to.
Question
I have integrated Nokia's MMS implementation for android (http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html) into an android application I am writing and I am able to send MMS's from my personal Metro PCS device to Metro PCS's MMSC and messages are delivered to any recipient without issue.
This is how I am sending the MMS:
public Boolean sendMMSMessage(final String senderNumber, final String smsText, final File imageFile, final Integer requestId){
byte[] out;
Enumeration keys;
//set image File
setImageFile(imageFile);
//create MMMessage
setMMMessage(new MMMessage());
//add text
addText(getMMMessage(),smsText,"<0>",IMMConstants.CT_TEXT_PLAIN);
//add image file
addFromFile(getMMMessage(),getImageFile(),"<1>",IMMConstants.CT_IMAGE_JPEG);
//set MMEncoder
setMMEncoder(new MMEncoder());
getMMEncoder().setMessage(getMMMessage());
//transaction ID (second parameter) is arbitrary
setMessage(getMMMessage(),"T135d743a6b7",senderNumber);
try {
getMMEncoder().encodeMessage();
out = getMMEncoder().getMessage();
setMMSender(new MMSender());
getMMSender().setMMSCURL("http://mms.metropcs.net:3128/mmsc");
//'min' of sending device. Required by Metro PCS MMSC.
getMMSender().addHeader("X-DEVICE-MIN", min);
setMMResponse(getMMSender().send(out));
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
return (getMMResponse().getResponseCode()==IMMConstants.HTTP_RESPONSE_OK);
}
I am wondering if it is possible to 'tweak' Nokia's code (if this is necessary) such that any device can send a properly constructed MMS request to Metro PCS's MMSC using my 'min' credentials. I have studied the packet flow (via 'WireShark') of what occurs when an MMS is successfully sent from my particular device to other recipients however when I run this same android app. on another device (a non-Metro PCS device), MMS messages fail to send and 'WireShark' is not helpful in explaining why. Can anyone help lead me in the direction of how I might make this work?
Update: It may help to add that logcat reports:
java.net.SocketTimeoutException: Connection timed out
Second Update: I took a look at another post regarding this issue. It is titled "Android sending image via MMS programatically(Operation timed out)" but unfortunately there currently is not a definite answer and this question has been live for two months. I will try increasing the read 'timeout' as someone suggested (I doubt this is the cause) but if anyone DOES know what the problem might be but simply wishes not to provide a direct answer this is fine. I just need a hint of where to look.
Third Update: Now that I think about it, I wonder if the senders IP address (the actual IP address used by the device) constitutes a factor here. Can anyone confirm?
Fourth Update: I just took a closer look at the code for 'MMSender.java' (specifically at whats going on with the 'HttpURLConnection' object) and according to its setReadTimeout(ms) method, the default value ('0') establishes an infinite wait time anyways and this method is not called anywhere in the code. Just for kicks, however, I manually set this value to 1 minute for both setConnectionTimeout(ms) and setReadTimeout(ms) and as I suspected, no dice. Same connect timeout issue.
Final Update: Sorry. I just realized that I copied this line of code from another posting some time ago:
((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,"enableSUPL");
and now after looking at this call more closely, I wonder if it is possible that I am supplying incorrect parameter values to startUsingNetworkFeature() (at least for the non-Metro PCS device I am trying the application on). I don't want to overkill my 'updates' here for this question but I want you guys (or gals) to be well informed so...; if these parameter values do turn out to be the problem, I will definitely post that fact but this will be my final update. In the mean time, any advice is greatly appreciated.