android app crashes on calling new activity

Hello,

i have an android app i am working on i am new to android so i have a new activity that i wanted to start that was an entry form but when i call the activity the app crashes on my phone

here is the code for the button call to open the activity
       // / / / / / / / / / / / / / / / / / / / / / /
        //Initialize forms of the ImageButtons
        // / / / / / / / / / / / / / / / / / / / / / /
        /* Button */
        ImageButton pcaButton = (ImageButton)findViewById(R.id.reg);

        // / / / / / / / / / / / / / / / / / / / / / /
        //Attach the Listener (On Click Event handler)
        // / / / / / / / / / / / / / / / / / / / / / /
        pcaButton.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this , Register.class);
                startActivity(intent);
            }
        });

Open in new window

LVL 1
Chris JonesLead Application Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris JonesLead Application Web DeveloperAuthor Commented:
any help would be awesome
0
KRUNAL TAILORFreelance Mobile DeveloperCommented:
Hi Chris Jones,

Can you please paste your Android manifest file code, because there you need to add activity of new view.
See this tutorial for ref: http://www.javatpoint.com/android-explicit-intent-example

Thanks & Regards,
Krunal T. Tailor
0
Chris JonesLead Application Web DeveloperAuthor Commented:
here is the manifest file.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="info.joneschris.joneschris_findme4" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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=".DeviceListActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog"/>
        <service android:enabled="true" android:name=".UartService" />

        <activity android:name=".Register"/>
    </application>

</manifest>

Open in new window

0
KRUNAL TAILORFreelance Mobile DeveloperCommented:
Hi Chris Jones,

Problem is within your manifest file. Edit your code something like this.

MainActivity.java

public class MainActivity extends Activity {

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

        ImageButton pcaButton = (ImageButton)findViewById(R.id.imageButton);
        pcaButton.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this , RegisterActivity.class);
                startActivity(intent);
            }
        });
    }
}

Open in new window


RegisterActivity.java

public class RegisterActivity extends Activity {

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


    }
}

Open in new window


AndroidManifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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=".RegisterActivity" android:label="@string/app_name" />
        <!--<service android:enabled="true" android:name=".UartService" />-->

Open in new window



If you not get then let me know.

Thanks & Regards,
Krunal T. Tailor
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris JonesLead Application Web DeveloperAuthor Commented:
works great thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Android

From novice to tech pro — start learning today.