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

  • SEARCH
  • Home
  • 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 8974367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:39:54+00:00 2026-06-15T18:39:54+00:00

I have already had this problem and solved it before with stackoverflows help but

  • 0

I have already had this problem and solved it before with stackoverflows help but it has came back again. When I click on one of the buttons it is ment to open a new activity but the app forcecloses.

MainMenu

package com.example.musicbynumbers;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;

public class MainMenu extends Activity implements View.OnClickListener  {
    Button majScales, minHarm, minMel;
    ImageButton mainMenu;
    Intent j;
    Intent k;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_menu);
         j = new Intent(this, majorScales.class);
          k = new Intent(MainMenu.this, minorHarmonic.class);
        mainMenu = (ImageButton) findViewById(R.id.imagelogo);
        majScales = (Button) findViewById(R.id.majorscalesb);
        minHarm = (Button) findViewById(R.id.minorharmonicb);
        minMel = (Button) findViewById(R.id.minormelodicb);
        majScales.setOnClickListener(this);
        mainMenu.setOnClickListener(this);
        minHarm.setOnClickListener(this);
        minMel.setOnClickListener(this);



    }




         @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                switch(arg0.getId()){
                case R.id.imagelogo:
                    Intent i =  new Intent(MainMenu.this, MainMenu.class);
                    startActivity(i);
                    break;
                case R.id.majorscalesb:

                    startActivity(j);
                    break;
                case R.id.minorharmonicb:

                    startActivity(k);
                    break;
                case R.id.minormelodicb:
                    Intent l = new Intent(MainMenu.this, minorMelodic.class);
                    startActivity(l);
                    break;


    }

}
}

majorScales

package com.example.musicbynumbers;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;

public class majorScales extends Activity implements View.OnClickListener  {
    Button aflatmaj, amaj, bflatmaj, bmaj, cmaj, dflatmaj, dmaj, eflatmaj, emaj, fmaj, fsharpmaj, gmaj;  
    ImageButton mainMenu;
    Intent j;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_menu);
        j  = new Intent(this, display.class);
        mainMenu = (ImageButton) findViewById(R.id.imagelogo);
        aflatmaj = (Button) findViewById(R.id.aflatmajb);
        amaj = (Button) findViewById(R.id.amajb);
        bflatmaj = (Button) findViewById(R.id.bflatmajb);
        bmaj = (Button) findViewById(R.id.bmajb);
        cmaj = (Button) findViewById(R.id.cmajb);
        dflatmaj = (Button) findViewById(R.id.dflatmajb);
        dmaj = (Button) findViewById(R.id.dmajb);
        eflatmaj = (Button) findViewById(R.id.eflatmajb);
        emaj = (Button) findViewById(R.id.emajb);
        fmaj = (Button) findViewById(R.id.fmajb);
        fsharpmaj = (Button) findViewById(R.id.fsharpmajb);
        gmaj = (Button) findViewById(R.id.gmajb);
        mainMenu.setOnClickListener(this);
        aflatmaj.setOnClickListener(this);
        amaj.setOnClickListener(this);
        bflatmaj.setOnClickListener(this);
        bmaj.setOnClickListener(this);
        cmaj.setOnClickListener(this);
        dflatmaj.setOnClickListener(this);
        dmaj.setOnClickListener(this);
        eflatmaj.setOnClickListener(this);
        emaj.setOnClickListener(this);
        fmaj.setOnClickListener(this);
        fsharpmaj.setOnClickListener(this);
        gmaj.setOnClickListener(this);



    }




         @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                switch(arg0.getId()){
                case R.id.imagelogo:
                    Intent i =  new Intent(majorScales.this, MainMenu.class);
                    startActivity(i);
                    break;
                case R.id.aflatmajb:

                    startActivity(j);
                    break;
                case R.id.amajb:

                    startActivity(j);
                    break;
                case R.id.bflatmajb:

                    startActivity(j);
                    break;
                case R.id.bmajb:

                    startActivity(j);
                    break;
                case R.id.cmajb:

                    startActivity(j);
                    break;
                case R.id.dflatmajb:

                    startActivity(j);
                    break;
                case R.id.dmajb:
                    ;
                    startActivity(j);
                    break;
                case R.id.eflatmajb:
                    ;
                    startActivity(j);
                    break;
                case R.id.emajb:
                    ;
                    startActivity(j);
                    break;
                case R.id.fmajb:
                    ;
                    startActivity(j);
                    break;
                case R.id.fsharpmajb:
                    ;
                    startActivity(j);
                    break;
                case R.id.gmajb:
                    ;
                    startActivity(j);
                    break;



    }

}
}

minorHarmonic

package com.example.musicbynumbers;

import android.app.Activity;
import android.os.Bundle;

public class minorHarmonic extends Activity {

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

}

AndroidManifest

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.musicbynumbers.MainMenu"
            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.musicbynumbers.majorScales"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.musicbynumbers.majorScales" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
         <activity
            android:name="com.example.musicbynumbers.minorHarmonic"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.musicbynumbers.minorHarmonic" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>


</manifest>

UPDATE: I added minorHarmonic to the manifest and that activity opens it seems to be just majorScales.

  • 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-15T18:39:55+00:00Added an answer on June 15, 2026 at 6:39 pm

    You need to create your Intent after onCreate() has been called. Use this:

    Intent j;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_menu);
    
        j = new Intent(this, display.class);
    

    The reason sounds complicated: the reference to this in the Intent uses the Activity’s Context, but this Context isn’t valid until after onCreate().


    Addition:

    I noticed you are missing a few Activities from your manifest:

    <activity android:name=".display" />
    <activity android:name=".minorHarmonic" />
    // etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had a problem like this before with adding scores but never solved it
Apologies if this was already asked but, I have had a look and can't
I'm very sure this problem has been solved, but I can't find any information
first: My technical problem is already solved, so this is not urgent, but I
I had a problem with ARC and blocks but have solved the problem. Unfortunately
I have already read some posts, but no one helped me with my problem.
I have some questions derived from a problem that I have already solved through
I've already solved the problem, but I'll post it here for future reference and
I have been working on a json decode issue (which I have already had
I have already download and install this package to support HTML5 input type http://support.microsoft.com/kb/2468871

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.