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 9192855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:01:44+00:00 2026-06-17T21:01:44+00:00

Hey guys I’m creating an android application (I’m very new at it), and I’m

  • 0

Hey guys I’m creating an android application (I’m very new at it), and I’m trying to access a new activity window after i click on the sign in button, but once i click it, a window pops up that says something like “unfortunately “appname” has stopped” and exits out of the program. here is my code, can you see what is wrong with it? Thanks guys

This is the Login Class.java file

package com.example.smartsignoutv3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class LoginScreen extends Activity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_screen);

    ((Button)findViewById(R.id.sign_in_button)).setOnClickListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_login_screen, menu);
    return true;
  }
@Override
public void onClick(View arg0) {
    switch (arg0.getId()) {
    case (R.id.sign_in_button): {
        System.out.println("yo dawg");
        Intent i = new Intent(this, MainScreen.class);
        startActivity(i);
        return;
    }
    }
}
}

Here is the main activity screen that I want to open up after the sign in button has been clicked

package com.example.smartsignoutv3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;



public class MainScreen extends Activity {

private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gestureDetector;

@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_screen);

    gestureDetector = new GestureDetector(new MyGestureDetector());
    View mainview = (View) findViewById(R.id.welcome_screen);

    // Set the touch listener for the main view to be our custom gesture listener
    mainview.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (gestureDetector.onTouchEvent(event)) {
                return true;
            }
            return false;
        }
    });
}

class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    Intent intent = new Intent(MainScreen.this.getBaseContext(), MainScreen.class);

        if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
            return false;
        }

        // right to left swipe
        if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
        startActivity(intent);
        MainScreen.this.overridePendingTransition(
        R.anim.slide_in_right,
        R.anim.slide_out_left
        );
        // right to left swipe
        }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
        startActivity(intent);
        MainScreen.this.overridePendingTransition(
        R.anim.slide_in_left, 
        R.anim.slide_out_right
        );
        }

        return false;
    }

    // It is necessary to return true from onDown for the onFling event to register
    @Override
    public boolean onDown(MotionEvent e) {
            return true;
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_login_screen, menu);
    return true;
}

}

here is the android manifest file if that is needed

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smartsignoutv3"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.smartsignoutv3.LoginScreen"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.smartsignoutv3.MainScreen"
        android:label="@string/app_name">

    </activity>
</application>

  • 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-06-17T21:01:46+00:00Added an answer on June 17, 2026 at 9:01 pm

    Change the onCreate of your LoginScreen Activity from this

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_screen);
    
    ((Button)findViewById(R.id.sign_in_button)).setOnClickListener(this);
    }
    

    To this

    private Button button;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_screen);
    
       button = (Button)findViewById(R.id.sign_in_button).setOnClickListener(this);
    }
    

    And in your onClick just do this directly

    @Override
    public void onClick(View arg0) {
    switch (arg0.getId()) {
    case R.id.sign_in_button: 
        System.out.println("yo dawg");
        Intent i = new Intent(this, MainScreen.class);
        startActivity(i);
    
     break;
    
    
    }
    
      return true;
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I am new to android development, I am currently making an application.The
Hey guys I am working on android application. My app includes an activity which
Hey guys, I am very new to AJAX and and working on a rating
Hey guys so I'm a bit new to Android programming and I have an
Hey guys thanks for answering I'm really new to Android programming(I started today) and
Hey guys I'm trying to add an iframe to a page using append. In
Hey guys im trying to connect to an database and collect some data out
Hey Guys If I do this in mono touch: var alert = new UIAlertView
Hey Guys i am currently trying to stopping one tableviewcell from being editable. But
Hey guys i am trying to run this query in my postgres db but

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.