i want to open an Activity using Intents By following this code:
Intent i=new Intent("com.example.learn.CONNECTION");
@Override
protected void onCreate(Bundle savedInstanceState) {
.
.
.
server=(Button) findViewById(R.id.Server);
client=(Button) findViewById(R.id.Client);
server.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
i.putExtra("check", "server");
startActivity(i);
// TODO Auto-generated method stub
}
});
client.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
i.putExtra("check1","client");
startActivity(i);
}
}); Now In this Connection Activity I am checking it with:
if(getIntent().hasExtra("check"))
value = getIntent().getExtras().getString("check");
if(getIntent().hasExtra("check1"))
value = getIntent().getExtras().getString("check1");
But the code is not working it either receives client or server. How should i solve this problem is there any other way out. Any other suggestions not related to this code will also be accepted.