0

I'm using a button to switch activities, but logcat says that I havent declared the activity in my AndroidManifest.xml Ive checked at least five times, and it is in there. Im trying to switch to the fahrenheittocelsius class.

My main java page with the button is here:

package com.jordandebarth.supercalculator;


import com.jordandebarth.supercalculator.distance;
import com.jordandebarth.supercalculator.exponents;
import com.jordandebarth.supercalculator.nuclearfusion;
import com.jordandebarth.supercalculator.pythagorean;
import com.jordandebarth.supercalculator.fahrenheittocelsius;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.support.v4.app.NavUtils;


public class tab_view extends Activity {

    Button calculator, pythagorean, distance, exponent, temperature, nuclearfusion;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_view);
        calculator = (Button)findViewById(R.id.calculatorButton);
        pythagorean = (Button)findViewById(R.id.pythagoreanButton);
        distance = (Button)findViewById(R.id.distanceButton);
        exponent = (Button)findViewById(R.id.exponentsButton);
        temperature = (Button)findViewById(R.id.temperatureButton);
        nuclearfusion = (Button)findViewById(R.id.nuclearfusion);


        pythagorean.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent pythagoreanIntent = new Intent(getBaseContext(), pythagorean.class);
                startActivityForResult(pythagoreanIntent, 0);
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });
        distance.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent distanceIntent = new Intent(getBaseContext(), distance.class);
                startActivityForResult(distanceIntent, 0);
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });
        exponent.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent exponentIntent = new Intent(getBaseContext(), exponents.class);
                startActivityForResult(exponentIntent, 0);
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });
        temperature.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent temperatureIntent = new Intent(getBaseContext(), fahrenheittocelsius.class);
                startActivityForResult(temperatureIntent, 0);
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });
        nuclearfusion.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent nuclearfusionIntent = new Intent(getBaseContext(), nuclearfusion.class);
                startActivityForResult(nuclearfusionIntent, 0);
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });

    }




}

and my AndroidManifest is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jordandebarth.supercalculator"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".tab_view"
            android:label="@string/title_activity_tab_view" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <activty
            android:name=".fahrenheittocelsius"
            android:label="Fahrenheit to Celsius"
            ></activty>

        <activity
            android:name=".calculator"
            android:label="Calculator"  >
        </activity>
        <activity
            android:name=".pythagorean"
            android:label="Pythagorean Theorem"
            >

        </activity>
        <activity
            android:name=".distance"
            android:label="Distance Formula"
            ></activity>
        <activity 
            android:name=".exponents"
            android:label="Exponents"
            ></activity>

        <activity
            android:name=".nuclearfusion"
            android:label="Nuclear Fusion"
            ></activity>
    </application>


</manifest>
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173

2 Answers2

0

Replace all instances of getBaseContext() with tab_view.this.

Phil
  • 35,852
  • 23
  • 123
  • 164
0

startActivityForResult allows you to start activity and get some data back. Imagine that you have some file picker activity. Follow the answer link. And, if you're using startActivityForResult() it needs onActivityResult()

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Result OK.d.
    if (requestCode == resultCode) {
        // do something good
    }
}

Try to start your activity with below code -

Intent temperature = new Intent(tab_view.this, fahrenheittocelsius.class);
startActivity(temperature);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
Community
  • 1
  • 1
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173