Android FileInputStream and Socket

I have set server and run following codes. The server runs well but the android program stops while running. The android program is to input a certificate file and send it to server by socket. I don't know what's wrong with my codes. Thanks!

private Socket client; private Button button; private ObjectOutputStream out = null; AssetManager assetManager = getAssets(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { new Thread (new Runnable() { public void run() { try { client = new Socket("192.168.1.186", 4444); out = new ObjectOutputStream(client.getOutputStream()); AssetFileDescriptor afd = assetManager.openFd("client.crt"); FileInputStream in = afd.createInputStream(); CertificateFactory of = CertificateFactory.getInstance("X.509"); java.security.cert.Certificate ceof = of.generateCertificate(in); X509Certificate clientcert = (X509Certificate) ceof; out.writeObject(clientcert); } catch(Exception e) { e.printStackTrace(); } } }).start(); } }); }

Category:android Views:1 Time:2017-05-17

Related post

  • android java and sockets 2011-11-13

    I write client-server application. Client will run on android and server on plain java. I need to exchange data from client to server and then from server to client. My proble is that when I send file from client to server the server stuck on receivi

  • Android App, and socket 2011-07-14

    I want to implement an android app which could communicate with a Server via internet. Since everytime the Android app connects to Server, there will be a connection established, and Android app will maintain this connection for the purpose of receiv

  • Android: Bluetooth connection, socket and thread 2010-04-22

    I’m currently working on a Android project and is very newbie to the Android platform. It’s an exercise I got from an article where I have to create a twitterlike application so that one Android platform can write to another and it automatically is u

  • What is the best way to connect an android application and a php server using sockets? 2011-11-28

    What is the best way to connect an android application and a php server using sockets? I am trying to implement a chat system between multiple clients, but I know that PHP does not allow multithreads. Sorry for not giving enough information about wha

  • Android Client and PC Server communication using sockets 2012-04-14

    I am running a client on android emulator and server (java) on the same PC and am using socket programming. Attaching code below. Individually both are running fine but the actual data transfer is not happening and am not able to figure it out. Serve

  • I want to develop a socket based chatting app in Titanium compatible with Android, iPhone and Blackberry 2013-02-09

    I want to develop a socket based chatting app in Titanium compatible with Android, iPhone and Blackberry. Please give me suggestion about it --------------Solutions------------- If you want a "socket based chatting app", then you've already made deci

  • Stream from pc to android throw java sockets, it's possible or may use RTP or http? 2011-01-29

    I try a project in which I want to stream media from my java application which is running in my pc to my android app and vice versa.In my first try I believe that I can make a tcp or udp connection and stream bytes from pc app to the android app. But

  • SIP messages between android mobile and python server 2011-05-16

    I want to be able to send Sip Messages Between Android phone and Python Server so to be able to send my lat and lang in GPS appear on my Android mobile phone . because i cant open socket on my android mobile and i want to be able to send lat and lang

  • Connection between Android phone and python server Options 2011-05-16

    I want to be able to send Messages Between Android phone and Python Server so to be able to send my lat and lang in GPS appear on my Android mobile phone . because i cant open socket on my android mobile and i want to be able to send lat and lang (GP

  • Android application and an HTTP server on ubuntu 2011-06-13

    my problem is this: for a personal project, I have to connect to an Android application and an HTTP server on ubuntu (it must then send information to a robot control board). But at the level of communication with the server in both directions, I rea

  • WebSocket library for Android, iOS and Flash 2011-06-14

    can someone please provide an example of WebSocket implementation in Android, iOS(iPhone/iPad) and Flash (not flex!). I found some libraries but none of that work :). My browser WebSocket implementation is working great using Socket.IO, now I would l

  • Android 3.0 socket response latency 2011-08-10

    I have started an Android project utilizing socket programming. Platform is Android 3.0. Due to platform requirements I am applying the socket operations in AsyncTask. I connect to the server, send commands successfully but the problem is that the re

  • How to create a secure SSL connection between Android client and Java server? 2011-08-28

    I'm trying to create a secure TCP/IP connection between my android client and java server. Cryptography by far is not my strong point. I know I have to use the Bouncy Castle keystores, but I'm stuck. I need to create a self signed cert that I can use

  • Safe connection between Android application and Apache server 2012-01-20

    Below I explained what I need and in the answer I would like to get information what technology, what kind of protocols, services etc should I use. Also I know that there is a massive amount of information on the internet, but because there are so ma

  • Android Client TCP socket 2012-03-13

    I'm implementing a Android client and desktop server application. In Client, i extends a Thread class for sending and receiveing TCP messages. It will handle my messages and do something due to the message's meaning. But the messages doesnot come fro

  • Real-time syncing with Android app and Google Drive 2012-04-25

    I'm wondering if it's feasible to utilize Google Drive to perform real-time syncing of custom documents between different users on different devices (Android, iOS, web, etc). What I'm talking about is similar to the real-time collaboration capabiliti

  • Python and sockets +upnp 2009-04-04

    I have a question about python and sockets. As I understand, if you have router you must open a port before you can use it in your program. But if user can't do that... I heard something about UPnP. I don't know will it help with my problem, so I've

  • FileInputStream and FileOutputStream line by line 2009-11-20

    FileInputStream reads all bytes of a file and FileOutputStream writes allbytes to a file which class do i use if i want to read all bytes of a file but line by line so that if fileA contains two lines line1 line2 then bytes of line1 and line2 are rea

  • Unit testing Android apps and specifically related to db's 2009-12-18

    What is the easiest way to create some kind of test harness for Android apps and to be able to visualize (even on the emulator) what is going into the db? I want to test things like constraints, look at the data, unit test methods, etc. Is there any

  • Android - drag and drop - list rearrange 2009-12-21

    How can I create a list where I can rearrange list items with dragging list rows to another row and so on (to change to order)? Just like on the HTC Hero in the clocks app where you can rearrange the order of clocks? Wouter --------------Solutions---

  • Android securityException and user contacts 2009-12-23

    I have am wrighting an android app and as a part of the app I would like the user to be able to see, select,and modify the user contacts. My main activity extends the TabActivity for usability reasons(from the users side). So in a tab i would like to

  • File sharing between Android phone and a PC 2010-01-18

    I am new to the Android SDK. Is there a way to share files from my Android app, so that it can be accessed by another computer using WiFi? Is there support for something like SMB? (Android version on phone is 1.6) Thanks. --------------Solutions-----

  • How to download Google APIs using Android SDK and AVD manager (as it gives SHA-1 MessageDigest not available)? 2010-01-21

    I cannot download the Google APIs using the Android SDK and AVD manager. Whenever trying I get the error below: SHA-1 MessageDigest not available Any thoughts? --------------Solutions------------- I found either a work around or the right way to do t

  • Android SDK and AVD Manager where is Settings menu? 2010-02-03

    I am dealing with a problem discussed on many forums but they all say go to the "settings" menu on the "Android SDK and AVD Manager" screen. Yet I have installed in on multiple machines and do not see a Settings menu. Where is the menu? I have it ins

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.101 (s). 11 q(s)