TechnocraT TechnocraT - 1 year ago 71
Java Question

no activity performed on button click

I have added a new activity to my application which already had some other activities. I am trying to make my new activity as main activity.when a button is clicked the previously existing activities should be called.

My problem is when i click the button no activity is performed.

I have made changes in manifest file as well.

My first intent has

login = (Button) findViewById(;
login.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
// TODO Auto-generated method stub

Toast.makeText(getApplicationContext(), "Invalid UserName or Password", Toast.LENGTH_LONG);
Intent main = new Intent(getApplicationContext(), OpenNMS.class);
} else {
Toast.makeText(getApplicationContext(), "Invalid UserName or Password", Toast.LENGTH_LONG);

my manifest file is

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Login"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

<activity android:name=".OpenNMS" android:label="@string/app_name">

Answer Source

In your code you haven't added show() to the Toast message,

Toast.makeText(getApplicationContext(), "Invalid UserName or Password", Toast.LENGTH_LONG);

It should be like this

Toast.makeText(getApplicationContext(), "Invalid UserName or Password", Toast.LENGTH_LONG).show();

So, it might be going in your else part where you are not able to see the Toast.

Thanks. Suri Sahani.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download