I want to download data using HttpConnection , see the example below
class ConnectionThread extends Thread
{
public void run()
{
try{
showToast("in the run method");
HttpConnection conn = null;
String URL = "http://xxxxxxx.com/api/api.php?func=showAllCountries;interface=wifi";
conn = (HttpConnection)Connector.open(URL);
}catch(Exception e){
showToast(e+"");
}
}
while running above code , on simulator it says Java.io.IOException No Wi-Fi connection found , Though in manage connection i can see simultor is conncted with Wifi ,
please why this is happening
Please
use deviceside= false;
in simulator wifi is not possible, simulator will access your system network , once you are on real device wifi will work if it is enabled in device.
Follow this link on how to make connections.
Related
I have a UWA on RPi 3 with Win 10 version 10.0.14393.0 and VS 2015 Update 3. I'm trying to run a TCPListener on my RPi, code runs with no exception but never can connect it, seems that some things block my connection. there is no hardware or software Firewall in path. I tried both background and foreground app but no result.
My code is as below :
namespace TestBackPort
{
public sealed class StartupTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
TcpListener tcpListener = null;
tcpListener = new TcpListener(IPAddress.Parse("192.168.1.9"), 1100);
tcpListener.Start();
var task = HandleConnectionsAsync(tcpListener);
task.Wait();
}
int connectionNumber = 0;
async Task HandleConnectionsAsync(TcpListener listener)
{
while (true)
{
var client = await listener.AcceptTcpClientAsync();
// Console.WriteLine("OK #" + connectionNumber);
connectionNumber++;
}
}
}
}
First of all, check your network state using "netstat" utility.
Connect to your raspberry pi using putty or powershell
Do "netstate -a" to verify that the TCP server is actually listening on that port.
When you have your server running, you should see something similar to below
Secondly, make sure you have the Internet Server capability enabled in the project manifest file. It could be either the Internet or the Private Networks, like below.
I have the following scenario to be automated. How this could be achieved through Appium.
1. Launch my application register a user with an gmail id.
2. Close the application.
3. Launch Safari browser and navigate to gmail login
4. Click on the registration link.
Here, challenging part is point number 2 and 3.
Can Appium session be disconnected?
Can Appium start a new session for a pre installed application like Safari?
You can just use the same appium server instance. No need to kill the server, but you will want to probably use two different driver instances.
AppiumDriverLocalService service;
IOSDriver iosDriver;
public void setUp() throws IOException {
service = AppiumDriverLocalService.buildDefaultService();
service.start();
}
public void startMyApplication(){
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
dc.setCapability(MobileCapabilityType.UDID, "3838n838fn38jf8n838ffabcdefg");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
dc.setCapability(MobileCapabilityType.APP, "com.your_package.name");
iosDriver = new IOSDriver("http://localhost:4723/wd/hub", dc);
}
public void testMyGoogleLoginOnMyApplication(){
//I intend to do something here
//Once i am finished, I close my application
iosDriver.quit();
}
public void startSafari(){
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
dc.setCapability(MobileCapabilityType.UDID, "3838n838fn38jf8n838ffabcdefg");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
dc.setCapability(MobileCapabilityType.APP, "com.safari_package.name");
iosDriver = new IOSDriver("http://localhost:4723/wd/hub", dc);
}
public void testSafari(){
//I intend to go to google and do stuff
//Once i am finished, I close my application
iosDriver.quit();
}
public void finished(){
service.stop();
}
Just came across a solution that works for all iOS versions and Xcode versions:
driver.background_app(-1)
From the springboard, find the Icon and click it!
import com.mchange.v2.c3p0.*;
import java.sql.*;
public class DBconnectionpool{
public static void main(String ar[]) throws Exception{
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "oracle.jdbc.driver.OracleDriver" );
cpds.setJdbcUrl( "jdbc:oracle:thin:#localhost:1521:xe" );
cpds.setUser("bms");
cpds.setPassword("abc");
cpds.setInitialPoolSize(5);
Connection con = cpds.getConnection();
System.out.println("got the connection"+con);
}
}
after Executing the above code ,In the Oracle monitor page i'm unable to see the 5 physical connections (i.e as i have set cpds.setInitialPoolSize(5)) instead i see only one connection.
your program exits immediately after one Connection is acquired. try sleeping for 30000 ms after you've acquired your Connection.
Trying to connect via Wi-Fi and I have an issue with the OS6 cd variable is null but it works on OS5
This is the url Strng: https://api3.popfax.com/index.php?service=Popfax;interface=wifi;interface=wifi
public ServiceConnectionBlackBerry(String s) throws IOException {
ConnectionFactory cf = new ConnectionFactory();
ConnectionDescriptor cd = cf.getConnection(s);
if (cd!=null){
connection = (HttpConnection) cd.getConnection();
}else {
System.out.println("Strng: "+s);}
}
can someone help please.
When using ConnectionFactory you should not append any connection information to your URL. So instead you should just pass https://api3.popfax.com/index.php?service=Popfax to your method.
Open a Wi-Fi HTTPS connection may help you.
thanks
I am trying to build a simple application for testing purpose in which I am making a simple Http connection .The code is running perfectly on the simulator but when I am testing the app on the real device it is not returning any response code. I think there is some error in http connection .
Here is the code that I am using for http connection:
httpConnection = (HttpConnection)Connector.open("http://www.google.com");
The device that I am using is Blackberry 8520 v5.0.0.592
Also give me some tips on how to do the debuging of any app from real device using eclipse plugin.
Thanks in advance.
If it is enough that your program works with OS 5.0+, then try using Network API:
ConnectionFactory f = new ConnectionFactory();
ConnectionDescriptor descr = f.getConnection("http://www.google.com");
HttpConnection connection = (HttpConnection) descr.getConnection();
That piece of code tries to use the first available connection type. You can fine tune it if you want.
Regarding debugging, just install BlackBerry Desktop Software, connect your 8520 with the USB cable and from eclipse, click Run -> Debug As... -> BlackBerry Device.
The connection factory worked perfectly on the new devices, but didn't work with some of the older ones like the curve and bold. This is what solved it for me:
BrowserField browserField = new BrowserField();
BrowserFieldRequest Req = new BrowserFieldRequest("http://www.yourserver.com/");
InputStream inputStream = browserField.getConnectionManager().makeRequest(Req).openInputStream();
Try to redirect the link using following code:
HttpConnection hc = (HttpConnection) Connector.open(url1);
hc.setRequestMethod(HttpConnection.GET);
hc.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
InputStream is = null;
String location =hc.getHeaderField("Location");
HttpConnection hcc = (HttpConnection) Connector.open(location);
is = hcc.openDataInputStream();
Try to add transport to address
For example for connect via wi-fi :
httpConnection = (HttpConnection)Connector.open("http://www.google.com;interface=wifi");