Friday, August 10, 2012

[android-developers] Re: How to use apache thrift with android????

package com.test.a;

import java.util.List;

import getsearch.Getsearch;
import getsearch.Urlget;
import mainservice.Mainservice;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class NewthriftActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//this code is used to cretae an client
try{
TTransport transport = new TSocket("107.20.177.28", 8888);
transport.open();
//TProtocol protocol = new TBinaryProtocol(transport);
//Mainservice.Client client = new Mainservice.Client(protocol);
//upto this line is common code for client need not to touch

//below call any API using client object created above
//like I have call add API which take some input and return output
/*System.out.println(client);
Getsearch g=new Getsearch();
g.rows="5";
g.text="india";
g.page=Integer.toString(2);

// System.out.println(client.get_search(g));
//System.out.println("The Sum is: "+sum);

//close client socket
List<Urlget> a=client.get_search(g);
Urlget b=a.get(0);
String ak= b.getName();
*/
Toast.makeText(getBaseContext(), "ak", Toast.LENGTH_LONG).show();
//transport.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

thanks riderj..the application is error free now but client is not communicating with server the client code is attached plz if u give a simple android client code which can communicate with thrift enabled server....plzzzz help me to get overcome this problem..

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate