I am exploring Xively Framework using Android client.
I have installed "service" given in Demo application.
When I start app on Android 2.3 and 4.0 device it is crashing .
Below is stack track for the same.Surprisingly it is working on Android 4.1.
Any suggestion what need to done do make it work on Android 2.3 and 4.0 devices
Stacktrace
10-25 18:25:18.854: D/HttpService(17080): onCreate()
10-25 18:25:18.874: W/dalvikvm(17080): Exception Ljava/lang/RuntimeException; thrown while initializing Landroid/os/AsyncTask;
10-25 18:25:18.884: E/JavaBinder(17080): * Uncaught remote exception! (Exceptions are not yet supported across processes.)
10-25 18:25:18.884: E/JavaBinder(17080): java.lang.ExceptionInInitializerError
10-25 18:25:18.884: E/JavaBinder(17080): at com.xively.android.service.HttpService.executeRequest(HttpService.java:276)
10-25 18:25:18.884: E/JavaBinder(17080): at com.xively.android.service.HttpService.put(HttpService.java:235)
10-25 18:25:18.884: E/JavaBinder(17080): at com.xively.android.service.HttpService.access$1(HttpService.java:232)
10-25 18:25:18.884: E/JavaBinder(17080): at com.xively.android.service.HttpService$1.updateFeed(HttpService.java:73)
10-25 18:25:18.884: E/JavaBinder(17080): at com.xively.android.service.IHttpService$Stub.onTransact(IHttpService.java:77)
10-25 18:25:18.884: E/JavaBinder(17080): at android.os.Binder.execTransact(Binder.java:338)
10-25 18:25:18.884: E/JavaBinder(17080): at dalvik.system.NativeStart.run(Native Method)
10-25 18:25:18.884: E/JavaBinder(17080): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
10-25 18:25:18.884: E/JavaBinder(17080): at android.os.Handler.(Handler.java:121)
10-25 18:25:18.884: E/JavaBinder(17080): at android.os.AsyncTask$InternalHandler.(AsyncTask.java:607)
10-25 18:25:18.884: E/JavaBinder(17080): at android.os.AsyncTask$InternalHandler.(AsyncTask.java:607)
10-25 18:25:18.884: E/JavaBinder(17080): at android.os.AsyncTask.(AsyncTask.java:190)
10-25 18:25:18.884: E/JavaBinder(17080): ... 7 more
10-25 18:25:18.884: W/dalvikvm(17080): threadid=9: thread exiting with uncaught exception (group=0x40c2e1f8)
10-25 18:25:18.884: E/AndroidRuntime(17080): FATAL EXCEPTION: Binder Thread #1
10-25 18:25:18.884: E/AndroidRuntime(17080): java.lang.ExceptionInInitializerError
10-25 18:25:18.884: E/AndroidRuntime(17080): at com.xively.android.service.HttpService.executeRequest(HttpService.java:276)
10-25 18:25:18.884: E/AndroidRuntime(17080): at com.xively.android.service.HttpService.put(HttpService.java:235)
10-25 18:25:18.884: E/AndroidRuntime(17080): at com.xively.android.service.HttpService.access$1(HttpService.java:232)
10-25 18:25:18.884: E/AndroidRuntime(17080): at com.xively.android.service.HttpService$1.updateFeed(HttpService.java:73)
10-25 18:25:18.884: E/AndroidRuntime(17080): at com.xively.android.service.IHttpService$Stub.onTransact(IHttpService.java:77)
10-25 18:25:18.884: E/AndroidRuntime(17080): at android.os.Binder.execTransact(Binder.java:338)
10-25 18:25:18.884: E/AndroidRuntime(17080): at dalvik.system.NativeStart.run(Native Method)
10-25 18:25:18.884: E/AndroidRuntime(17080): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
10-25 18:25:18.884: E/AndroidRuntime(17080): at android.os.Handler.(Handler.java:121)
10-25 18:25:18.884: E/AndroidRuntime(17080): at android.os.AsyncTask$InternalHandler.(AsyncTask.java:607)
10-25 18:25:18.884: E/AndroidRuntime(17080): at android.os.AsyncTask$InternalHandler.(AsyncTask.java:607)
10-25 18:25:18.884: E/AndroidRuntime(17080): at android.os.AsyncTask.(AsyncTask.java:190)
10-25 18:25:18.884: E/AndroidRuntime(17080): ... 7 more
There is a known issue wit the Android library. There is an open issue in Github. The team is working on testing a fix but basically it is a user contributed library that is highly unstable.
You are best off using HttpClient and performing the API functions from there. This will allow you to use Xively with Android.
Related
Following this tutorial: Getting started with Android.
I try to create my first phonegap project using Eclipse. However, when clicking on the icon of "Cordova Example"(name of the application from the example of PhoneGap) on the screen of device. An error named : "the application Cordova Example (process org.apache.cordova.example) has stopped unexpectedly. Please try again" occurs.
This is the log file when error occurs:
01-02 09:40:46.280: D/AndroidRuntime(310): Shutting down VM
01-02 09:40:46.280: W/dalvikvm(310): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-02 09:40:46.308: E/AndroidRuntime(310): FATAL EXCEPTION: main
01-02 09:40:46.308: E/AndroidRuntime(310): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.apache.cordova.example/org.apache.cordova.example.cordovaExample}: java.lang.ClassNotFoundException: org.apache.cordova.example.cordovaExample in loader dalvik.system.PathClassLoader[/data/app/org.apache.cordova.example-2.apk]
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.os.Looper.loop(Looper.java:123)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-02 09:40:46.308: E/AndroidRuntime(310): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 09:40:46.308: E/AndroidRuntime(310): at java.lang.reflect.Method.invoke(Method.java:521)
01-02 09:40:46.308: E/AndroidRuntime(310): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-02 09:40:46.308: E/AndroidRuntime(310): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-02 09:40:46.308: E/AndroidRuntime(310): at dalvik.system.NativeStart.main(Native Method)
01-02 09:40:46.308: E/AndroidRuntime(310): Caused by: java.lang.ClassNotFoundException: org.apache.cordova.example.cordovaExample in loader dalvik.system.PathClassLoader[/data/app/org.apache.cordova.example-2.apk]
01-02 09:40:46.308: E/AndroidRuntime(310): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-02 09:40:46.308: E/AndroidRuntime(310): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-02 09:40:46.308: E/AndroidRuntime(310): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-02 09:40:46.308: E/AndroidRuntime(310): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-02 09:40:46.308: E/AndroidRuntime(310): ... 11 more
The java.lang.ClassNotFoundException seems like can't find your Main Class, it could be a name problem of your java main class or in config.xml or in manifest, check all names are correctly.
Regards.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
10-25 05:30:06.560: W/dalvikvm(1428): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
10-25 05:30:06.670: E/AndroidRuntime(1428): FATAL EXCEPTION: main
10-25 05:30:06.670: E/AndroidRuntime(1428): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.androidhiv/com.example.androidhiv.AllProductsActivity}; have you declared this activity in your AndroidManifest.xml?
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Activity.startActivityForResult(Activity.java:3370)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Activity.startActivityForResult(Activity.java:3331)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Activity.startActivity(Activity.java:3566)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.Activity.startActivity(Activity.java:3534)
10-25 05:30:06.670: E/AndroidRuntime(1428): at com.example.androidhiv.MainScreenActivity$1.onClick(MainScreenActivity.java:31)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.view.View.performClick(View.java:4204)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.view.View$PerformClick.run(View.java:17355)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.os.Handler.handleCallback(Handler.java:725)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.os.Handler.dispatchMessage(Handler.java:92)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.os.Looper.loop(Looper.java:137)
10-25 05:30:06.670: E/AndroidRuntime(1428): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-25 05:30:06.670: E/AndroidRuntime(1428): at java.lang.reflect.Method.invokeNative(Native Method)
10-25 05:30:06.670: E/AndroidRuntime(1428): at java.lang.reflect.Method.invoke(Method.java:511)
10-25 05:30:06.670: E/AndroidRuntime(1428): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-25 05:30:06.670: E/AndroidRuntime(1428): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-25 05:30:06.670: E/AndroidRuntime(1428): at dalvik.system.NativeStart.main(Native Method)
Make sure that this Activity is register in Android Manifeast
You have not declared your Activity AllProductsActivity in your manifest file and the compiler is unable to find that Activity hence throwing error.
Declare Activity AllProductsActivity in your manifest file.
like this
<activity android:name="com.example.androidhiv.AllProductsActivity"
></activity>
Its showing that you have not declared your AllProductsActivity in your manifest file.
<activity
android:name="com.example.androidhiv.AllProductsActivity"
/>
You had to declare each and every Acticity which you want to show in your application it had to be declare in AndroidManifest.xml file.
<activity android:name="com.example.androidhiv.AllProductsActivity" />
I have a app that shows a ListView with several documents (DOC, PDF, PPT...). Selection one of them, I use the following code to show the document:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(outFile).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (extension.equalsIgnoreCase("") || mimetype == null) {
intent.setDataAndType(Uri.fromFile(outFile), "text/*");
} else {
intent.setDataAndType(Uri.fromFile(outFile), mimetype);
}
startActivity(Intent.createChooser(intent, "Choose an Application:"));
That works fine for the the first document selected, Polaris Office opens and show the document - fine. When switching back for selecting the next document, my application is not on the last screen shown, instead it starts again. Selecting the document works and open fine in Polaris. When now switching back, the app crashes with Unable to start activity ...MainActivity ... NullPointerExpetion.
What can I do to solve this problem?
Here the LogCat:
10-25 10:07:43.476: D/AndroidRuntime(8396): Shutting down VM
10-25 10:07:43.476: W/dalvikvm(8396): threadid=1: thread exiting with uncaught exception (group=0x415092a0)
10-25 10:07:43.507: E/AndroidRuntime(8396): FATAL EXCEPTION: main
10-25 10:07:43.507: E/AndroidRuntime(8396): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.astrex.ppastrex/com.astrex.ppastrex.MainActivity}: java.lang.NullPointerException
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread.access$600(ActivityThread.java:140)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.os.Handler.dispatchMessage(Handler.java:99)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.os.Looper.loop(Looper.java:137)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread.main(ActivityThread.java:4895)
10-25 10:07:43.507: E/AndroidRuntime(8396): at java.lang.reflect.Method.invokeNative(Native Method)
10-25 10:07:43.507: E/AndroidRuntime(8396): at java.lang.reflect.Method.invoke(Method.java:511)
10-25 10:07:43.507: E/AndroidRuntime(8396): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
10-25 10:07:43.507: E/AndroidRuntime(8396): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
10-25 10:07:43.507: E/AndroidRuntime(8396): at dalvik.system.NativeStart.main(Native Method)
10-25 10:07:43.507: E/AndroidRuntime(8396): Caused by: java.lang.NullPointerException
10-25 10:07:43.507: E/AndroidRuntime(8396): at com.astrex.ppastrex.FrameDocumentos.onCreateView(FrameDocumentos.java:66)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.Activity.performStart(Activity.java:5173)
10-25 10:07:43.507: E/AndroidRuntime(8396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2070)
10-25 10:07:43.507: E/AndroidRuntime(8396): ... 11 more
I had a similar issue happening for me on Android 6.0, but not in 4.4, so for older devices, it would work fine and there would be no crash.
In my case, I was downloading a url, saving the file and opening them in 3rd party viewers.
I've discovered that as long as I save the pdf to the Downloads Directory, it fixes it for my situation.
File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File dir = new File(root.getAbsolutePath());
if (dir.exists() == false) {
dir.mkdirs();
}
String fileName = "filename.pdf";
file = new File(dir, fileName);
try like this:
File file = new File(pdfpath);
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
finish();
}
catch (ActivityNotFoundException e) {
}
}
The intent looks like it was called correctly it works for some. Seems like you'd have a null reference without checking if the file exists.
Experience tells me the null comes because your device ran out of memory while opening the pdf file so your app was shut down to free up some memory.
The solution is to add the savedinstancestate method saving what your app needs and check if the savedinstancestate != null in your oncreate method then recreate what your app needs from the savedinstancestate.
I want to connect my android application to my MSSQL Database.
Unfortunately, there is a problem :/
10-25 19:17:00.536: W/System.err(18961): java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
10-25 19:17:00.546: W/System.err(18961): at java.lang.Class.classForName(Native Method)
10-25 19:17:00.556: W/System.err(18961): at java.lang.Class.forName(Class.java:217)
10-25 19:17:00.556: W/System.err(18961): at java.lang.Class.forName(Class.java:172)
10-25 19:17:00.556: W/System.err(18961): at com.example.mssqlcon.MainActivity.onCreate(MainActivity.java:21)
10-25 19:17:00.556: W/System.err(18961): at android.app.Activity.performCreate(Activity.java:4465)
10-25 19:17:00.556: W/System.err(18961): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-25 19:17:00.556: W/System.err(18961): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
10-25 19:17:00.556: W/System.err(18961): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
10-25 19:17:00.556: W/System.err(18961): at android.app.ActivityThread.access$600(ActivityThread.java:132)
10-25 19:17:00.556: W/System.err(18961): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
10-25 19:17:00.556: W/System.err(18961): at android.os.Handler.dispatchMessage(Handler.java:99)
10-25 19:17:00.556: W/System.err(18961): at android.os.Looper.loop(Looper.java:137)
10-25 19:17:00.566: W/System.err(18961): at android.app.ActivityThread.main(ActivityThread.java:4575)
10-25 19:17:00.566: W/System.err(18961): at java.lang.reflect.Method.invokeNative(Native Method)
10-25 19:17:00.566: W/System.err(18961): at java.lang.reflect.Method.invoke(Method.java:511)
10-25 19:17:00.566: W/System.err(18961): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
10-25 19:17:00.566: W/System.err(18961): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
10-25 19:17:00.566: W/System.err(18961): at dalvik.system.NativeStart.main(Native Method)
10-25 19:17:00.566: W/System.err(18961): Caused by: java.lang.NoClassDefFoundError: net/sourceforge/jtds/jdbc/Driver
10-25 19:17:00.566: W/System.err(18961): ... 18 more
10-25 19:17:00.566: W/System.err(18961): Caused by: java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
10-25 19:17:00.576: W/System.err(18961): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-25 19:17:00.576: W/System.err(18961): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-25 19:17:00.576: W/System.err(18961): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-25 19:17:00.576: W/System.err(18961): ... 18 more
My code:
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(
"jdbc:jtds:sqlserver://ip_of_my_database", "*****", "*******");
Statement statement = connection.createStatement();
//ResultSet result = statement
// .executeQuery("SELECT * FROM nazwatabeli");
ResultSet result = statement.executeQuery("SELECT * FROM name");
if(result.first()){
do{
Log.v("MainActivity", "Name: "+result.getString(result.getRow()));
} while(result.next());
}
} catch (Exception e){
e.printStackTrace();
}
}
}
What I do wrong?
You can't access SQL server directly using the Android device. You have to use a kind of a webservice to gain the access to a server which have the SQL connected. You can use java or php to do this. Check the following link for java webservices with android.
http://sarangasl.blogspot.com/2011/10/android-web-service-access-tutorial.html
What is the SDK version you are using? If it is r20 or upper you have to include all the external library files which you are using to lib folder inside the project through out your project. Otherwise it will tell ClassNotFoundException.
Tell me if you want any clarification.
After the program running,click the send button,then pop-up dialog said the program has already exited。
I don‘t know what is the problem,how can I fix it?
Is there anybody has the same issue,can you help me?
package com.secion9.clienttest;
import android.os.Bundle;
import android.app.Activity;
import android.widget.*;
import java.net.Socket;
import java.io.IOException;
import java.io.OutputStream;
import android.view.View;
import android.view.View.OnClickListener;
public class ClientActivity extends Activity {
Button btSend;
EditText etMsg;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_client);
btSend=(Button)this.findViewById(R.id.button1);
etMsg=(EditText)this.findViewById(R.id.EditText1);
btSend.setOnClickListener(
new OnClickListener(){
public void onClick(View v)
{
try
{
Socket socket=new Socket("127.0.0.1",5050);
OutputStream outputStream=socket.getOutputStream();
byte[] buffer=etMsg.getText().toString().getBytes();
outputStream.write(buffer);
outputStream.flush();
}
catch(IOException e)
{
e.printStackTrace();
}
}
});
}
}
logcat
09-02 08:24:31.189: E/Trace(627): error opening trace file: No such file or directory (2)
09-02 08:24:32.259: D/gralloc_goldfish(627): Emulator without GPU emulation detected.
09-02 08:24:32.598: I/Choreographer(627): Skipped 40 frames! The application may be doing too much work on its main thread.
09-02 08:25:04.471: D/AndroidRuntime(627): Shutting down VM
09-02 08:25:04.471: W/dalvikvm(627): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
09-02 08:25:04.539: E/AndroidRuntime(627): FATAL EXCEPTION: main
09-02 08:25:04.539: E/AndroidRuntime(627): android.os.NetworkOnMainThreadException
09-02 08:25:04.539: E/AndroidRuntime(627): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
09-02 08:25:04.539: E/AndroidRuntime(627): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
09-02 08:25:04.539: E/AndroidRuntime(627): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
09-02 08:25:04.539: E/AndroidRuntime(627): at libcore.io.IoBridge.connect(IoBridge.java:112)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.Socket.startupSocket(Socket.java:566)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.Socket.tryAllAddresses(Socket.java:127)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.Socket.<init>(Socket.java:177)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.net.Socket.<init>(Socket.java:149)
09-02 08:25:04.539: E/AndroidRuntime(627): at com.secion9.clienttest.ClientActivity$1.onClick(ClientActivity.java:31)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.view.View.performClick(View.java:4084)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.view.View$PerformClick.run(View.java:16966)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.os.Handler.handleCallback(Handler.java:615)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.os.Handler.dispatchMessage(Handler.java:92)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.os.Looper.loop(Looper.java:137)
09-02 08:25:04.539: E/AndroidRuntime(627): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 08:25:04.539: E/AndroidRuntime(627): at java.lang.reflect.Method.invoke(Method.java:511)
09-02 08:25:04.539: E/AndroidRuntime(627): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-02 08:25:04.539: E/AndroidRuntime(627): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-02 08:25:04.539: E/AndroidRuntime(627): at dalvik.system.NativeStart.main(Native Method)
09-02 08:25:07.079: I/Process(627): Sending signal. PID: 627 SIG: 9
It sounds like you're doing networking on the main thread. That's a no-no:
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html
SOLUTION:
Modify your app so that it spawns off a thread or async task to do the network I/O.
Here's a good link that discusses how:
http://www.vogella.com/articles/AndroidPerformance/article.html
Have put in AndroidManifest.xml Internet permission?
Regards,
Skipped 40 frames! The application may be doing too much work on its main thread.
and
NetworkOnMainThreadException
Are there to tell you that you're blocking the main thread, which causes and ANR and the app can get killed :)
Try to implement your network stuff on a background thread, or with an AsyncTask
According to the documentation at [Android Developers][1]:
The exception that is thrown when an application attempts to perform a
networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or
higher. Applications targeting earlier SDK versions are allowed to do
networking on their main event loop threads, but it's heavily
discouraged.
So you need to target a lower SDK or make a new thread for handling networks connections.