Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:49:01+00:00 2026-05-27T01:49:01+00:00

Basically I want to have a button to start a new activity after login.

  • 0

Basically I want to have a button to start a new activity after login.
I found that I was not able to call the StartActivity() as what I did before in the login page.Please guide

This is the login page where I used StartActivity(this,sth.class)sucessfully

public class Login extends Activity
{

/** Called when the activity is first created. */


Button login;
String name="",pass="";
EditText username,password;
TextView tv;
byte[] data;
HttpPost httppost;
StringBuffer buffer;
HttpResponse response;
HttpClient httpclient;
InputStream inputStream;
SharedPreferences app_preferences ;
List<NameValuePair> nameValuePairs;
CheckBox check;


public void onCreate(Bundle savedInstanceState)

{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    app_preferences = PreferenceManager.getDefaultSharedPreferences(this);

    username = (EditText) findViewById(R.id.username);
    password = (EditText) findViewById(R.id.password);
    login = (Button) findViewById(R.id.login);
    check = (CheckBox) findViewById(R.id.check);

     String Str_user = app_preferences.getString("username","0" );
    String Str_pass = app_preferences.getString("password", "0");

    String Str_check = app_preferences.getString("checked", "no");
    if(Str_check.equals("yes"))

    {
            username.setText(Str_user);
            password.setText(Str_pass);
            check.setChecked(true);
    }

    login.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)

        {

            name = username.getText().toString();

            pass = password.getText().toString();

            String Str_check2 = app_preferences.getString("checked", "no");

            if(Str_check2.equals("yes"))

            {

                SharedPreferences.Editor editor = app_preferences.edit();

                editor.putString("username", name);

                editor.putString("password", pass);

                 editor.commit();

            }

            if(name.equals("") || pass.equals(""))

            {

                 Toast.makeText(Login.this, "Blank Field..Please Enter", Toast.LENGTH_LONG).show();

            }

            else

            {



            try {

                httpclient = new DefaultHttpClient();

                httppost = new HttpPost("http://fyptest.comyr.com/main.php");

                // Add your data

                nameValuePairs = new ArrayList<NameValuePair>(2);

               nameValuePairs.add(new BasicNameValuePair("UserEmail", name.trim()));

                nameValuePairs.add(new BasicNameValuePair("Password", pass.trim()));

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));



                // Execute HTTP Post Request

                response = httpclient.execute(httppost);

                inputStream = response.getEntity().getContent();



                data = new byte[256];



                buffer = new StringBuffer();

                int len = 0;

                while (-1 != (len = inputStream.read(data)) )

                {

                    buffer.append(new String(data, 0, len));

                }


                inputStream.close();

            }



            catch (Exception e)

            {

                Toast.makeText(Login.this, "error"+e.toString(), Toast.LENGTH_LONG).show();

            }

            if(buffer.charAt(0)=='Y')

            {

                Toast.makeText(Login.this, "login successfull", Toast.LENGTH_LONG).show();
                Move_to_next();

            }

            else
        {

                Toast.makeText(Login.this, "Invalid Username or password", Toast.LENGTH_LONG).show();

            }

            }

        }

    });

    check.setOnClickListener(new View.OnClickListener()

    {

        public void onClick(View v)

        {

            // Perform action on clicks, depending on whether it's now checked

            SharedPreferences.Editor editor = app_preferences.edit();

            if (((CheckBox) v).isChecked())

            {



                 editor.putString("checked", "yes");

                 editor.commit();

            }

            else

            {

                 editor.putString("checked", "no");

                 editor.commit();

            }

        }

    });

}



public void Move_to_next()

    {

     //may perform checking based on ID

      startActivity(new Intent(this, MainMenu.class));

    }

But this, my startActivity is being underlined in red

public class MainMenu extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu);

    Button new_folder = (Button)findViewById(R.id.new_folder);
    new_folder.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            // show another class 
            startActivity(new Intent(this,Folder_Details.class));

        }

    });
}

}

It shows “The constructor Intent(new View.OnClickListener(){}, Class) is undefined” and “Remove arguments to match Intent()” options

I have included the <Activity></Activity> in Manifest. And the code showed above, imports are cut off

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:49:02+00:00Added an answer on May 27, 2026 at 1:49 am

    Yes this is because, you are trying to use “this” with refernce to your button instead of your activity. You have to replace it like this,

    Instead of startActivity(new Intent(this, Folder_Details.class));

    do this,

    startActivity(new Intent(MainMenu.this, Folder_Details.class));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view that I want to basically take care of itself
We have a air/flex app that we want to add an effect to. Basically
I have an Activity MyActivity with a Button MyButton . I want to attach
Basically I want to be able to have a custom control: public class MyControl
So I basically want to have a static method in my AR class to
i'm experimenting with django and the builtin admin interface. I basically want to have
Basically I want to have our installer also install the .NET framework and any
This is what I'm talking about: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx basically I want to have a drop
I have a 2-dimensional array of objects and I basically want to databind each
I have an SPListItemCollection. I basically want to get one of the items (randomly)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.