Click here to Skip to main content
15,886,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is when I open new activity when pressing button an error accoutred "Unfortunately, ISPcheck has stopped".
Here is my MainActivity.java button click event code:
Java
public void btnLogin_OnClick(View view) {
        startActivity(new Intent(MainActivity.this, PersonInfo.class));
    }


Here is button xml code in activity_main.xml:

HTML
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="تسجيل الدخول"
            android:id="@+id/btnLogin"
            android:layout_marginTop="72dp"
            android:textColor="#ffffff"
            android:layout_below="@+id/txtPassword"
            android:layout_centerHorizontal="true"
            android: önClick="btnLogin_OnClick" /
>


Here is AndroidManifest.xml code:
XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hsa.ispcheck"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.hsa.ispcheck.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="com.hsa.ispcheck.PersonInfo"
            android:label="@string/title_activity_person_info" >
        </activity>
    </application>

</manifest>



So, What's wrong with what I did?

Note: I'm using Android Studio v0.3.2
Posted
Updated 22-Dec-13 20:28pm
v2
Comments
cigwork 22-Dec-13 16:27pm    
Assuming you are using Eclipse and the Android plug-ins:

Have you tried running this in the emulator rather than directly on the target machine? If you do then the logcat window will (very probably) tell you where you've gone wrong.

If there's nothing showing in logcat wrap the failing code in a try/catch block and in the catch call android.util.Log.e method with the exception info.

catch (Exception e) {
Log.e("MyActivity::MyMethod", e.getMessage());
}

It's probably a null pointer or other uninitialised variable. It nearly always is for me. :)
Rasool Ahmed 23-Dec-13 2:29am    
I'm using Android Studio. And I ran it on emulator and same message above accord.
Xiao Ling 24-Dec-13 0:36am    
could you post the source code of PersonInfo?
tabrej 5-Jan-14 11:30am    
Kindly provide the Logcat output in order to fix the issue.

1 solution

Hi,

please use below code in your button click.

Java
Intent i = new Intent(getApplicationContext(), PersonInfo.class);
startActivity(i);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900