Hi, i am building and app which requires Server PC and Android client.
Although i am unable to call and activity using intend right after the
client connects. Any ideas? I really need help on this. I am posting my
files here Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
package my.hasham.joy.app;
import android.app.Activity;
import android.os.Bundle;
public class Acontroller extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
package my.hasham.joy.app;
import java.net.Socket;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MyAppActivity extends Activity {
/** Called when the activity is first created. */
Button mButton;
EditText mEdit;
String ip;
Socket s;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.addip);
mButton = (Button)findViewById(R.id.button1);
mEdit = (EditText)findViewById(R.id.editText1);
mButton.setOnClickListener(
new View.OnClickListener()
{
public void onClick(View v)
{
String ip = mEdit.getText().toString();
Wificlient getip = new Wificlient();
getip.createsock(ip,s);
Wificlient sock = new Wificlient();
sock.status(s);
if(sock==true){
Intent startAcontroller = new Intent("my.hasham.joy.app.ACONTROLLER");
startActivity(startAcontroller);
}
else{
Intent startAcontroller = new Intent("my.hasham.joy.app.ACONTROLLER");
startActivity(startAcontroller);
}
}
});
}
}
package my.hasham.joy.app;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
public class Wificlient {
String ip;
public Socket s;
public void createsock(String ip, Socket s){
try{
s = new Socket(ip,2222);
InputStream is = s.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
OutputStream os = s.getOutputStream();
PrintWriter pw = new PrintWriter(os,true);
}
catch(Exception ex){
//System.out.println(ex);
}
}
//connection check
public int status(Socket s){
boolean mysocket = s.isConnected();
if (mysocket==true){
return 1;
}
else{
return 2;
}
}
}