Unfortunately my app has stopped working

vaib

Here is my login activity class where i want to do login after login it show the map but when i run the app it show unfortunately stopped login

loginActivity.java

package com.ivb.login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity{
     EditText edtemail,edtPassword;
        Button btnLogin;
        String strUsername,strPassword;

      @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.login);
            edtemail = (EditText)this.findViewById(R.id.edt_email);
            edtPassword = (EditText)this.findViewById(R.id.edt_passwrd);
            btnLogin = (Button)this.findViewById(R.id.btnLogin);
            btnLogin.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    strUsername = edtemail.getText().toString().trim();
                    strPassword = edtPassword.getText().toString().trim();
                    if(strUsername.equals("[email protected]") && strPassword.equals("needin123"))
                        startActivity(new Intent(LoginActivity.this,LoginSuccess.class).putExtra("usr",(CharSequence)strUsername));
                     else 
                        Toast.makeText(LoginActivity.this,"Invalid UserName or Password", Toast.LENGTH_LONG).show();

                }
            });

            TextView registerScreen = (TextView) findViewById(R.id.link_to_register);

            // Listening to register new account link
            registerScreen.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    // Switching to Register screen

                    Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
                    startActivity(i);
                }
            });
        }

}

loginsuccess.java

package com.ivb.login;

import javax.security.auth.PrivateCredentialPermission;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;

public class LoginSuccess extends Activity {

    private GoogleMap googleMap;
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState); 
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.second);


            try {
                // Loading map
                initilizeMap();

            } catch (Exception e) {
                e.printStackTrace();
            }

            Intent in = getIntent();
            if (in.getCharSequenceExtra("usr") != null) {
                final TextView setmsg = (TextView)findViewById(R.id.showmsg);
                setmsg.setText("Welcome \n "+in.getCharSequenceExtra("usr"));               
            }

            }

    private void initilizeMap() {
        if (googleMap == null) {
            googleMap =((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

            // check if map is created successfully or not
            if (googleMap == null) {
                Toast.makeText(getApplicationContext(),
                        "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }
}

This the werror code which is shown in log cat

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ivb.login"
    android:versionCode="1"
    android:versionName="1.0" >
    <permission 
        android:name="com.ivb.login.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"></permission>
    <uses-permission android:name="com.ivb.login.permission.MAPS_RECEIVE"/>
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-feature 
        android:glEsVersion="0x00020000"
        android:required="true"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.ivb.login.LoginActivity"
            android:label="@string/app_name" 
            android:screenOrientation="sensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
          <activity android:name="com.ivb.login.RegisterActivity"
                  android:label="Register New Account"></activity>
          <activity android:name="com.ivb.login.LoginSuccess"></activity>
           <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyC-2jAJ7MEkho_gJv7KLeb-tHrU2zHDUQU" />
           <uses-library android:name="com.google.android.maps"/>
    </application>
</manifest>

second.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".LoginSuccess" >
<LinearLayout android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@layout/header_gradient"
                android:paddingTop="5dip"
                android:paddingBottom="5dip" >
                <ImageView android:src="@drawable/logo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dip"/>
</LinearLayout>
    <TextView
        android:id="@+id/showmsg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="Welcome"
        android:textSize="20dip" >

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </TextView>

</RelativeLayout>

login.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff" >

        <LinearLayout
            android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@layout/header_gradient" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/header"
            android:orientation="vertical"
            android:padding="10dip" >

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dip"
                android:src="@drawable/logo1" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Email"
                android:textColor="#372c24" />

            <EditText
                android:id="@+id/edt_email"
                android:layout_width="209dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="20dip"
                android:layout_marginTop="5dip"
                android:ems="10"
                android:hint="Enter Email Address"
                android:inputType="textEmailAddress"
                android:singleLine="true"
                android:typeface="normal" >

                <requestFocus />
            </EditText>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Password"
                android:textColor="#372c24" />

            <EditText
                android:id="@+id/edt_passwrd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="5dip"
                android:ems="10"
                android:hint="Enter password"
                android:inputType="textPassword"
                android:password="true"
                android:singleLine="true"
                android:typeface="normal" />

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="133dp"
                android:layout_height="32dp"
                android:layout_gravity="center"
                android:layout_marginTop="10dip"
                android:background="#acd28a"
                android:clickable="true"
                android:gravity="center"
                android:paddingLeft="15dip"
                android:text="Login" />

            <TextView
                android:id="@+id/link_to_register"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="40dip"
                android:layout_marginTop="40dip"
                android:gravity="center"
                android:text="Need an account?sign up"
                android:textColor="#0b84aa"
                android:textSize="20dip" />
        </LinearLayout>
    </RelativeLayout>

</ScrollView>
Piyush

Change from

<TextView
    android:id="@+id/showmsg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="Welcome"
    android:textSize="20dip" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</TextView>

to

<TextView
    android:id="@+id/showmsg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="Welcome"
    android:textSize="20dip" >
</TextView>

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

this is because your < /TextView> was closed after fragment class so you got this error.

Also change here

 startActivity(new Intent(LoginActivity.this,LoginSuccess.class).putExtra("usr",strUsername));

and also in your LoginSuccess Activity

        Intent in = getIntent();
        if (in.getStringExtra("usr") != null) {
            final TextView setmsg = (TextView)findViewById(R.id.showmsg);
            setmsg.setText("Welcome \n "+in.getStringExtra("usr"));               
        }

That means you have to declare this part in your manifest file...

<uses-feature android:glEsVersion="0x00020000" android:required="true/>

and must use latest updated Google Play Service.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unfortunately, app has stopped working?

From Dev

Unfortunately, app has stopped working?

From Dev

Unfortunately the app has stopped working

From Dev

My app has unfortunately stopped

From Dev

Unfortunately app has stopped working android emulator

From Dev

Unfortunately the app has stopped working error in Android

From Dev

Unfortunately your "APP" has stopped working

From Dev

Unfortunately my app has stopped in Android Emulator

From Dev

“Unfortunately My Android App has stopped”

From Dev

Android Studio: Unfortunately "my App" has stopped

From Dev

Unfortunately my app has stopped in Android Emulator

From Dev

Unfortunately App Has Stopped

From Dev

unfortunately my app has stopped (my first app in android)

From Dev

unfortunately,myapp has stopped working

From Dev

Android: Catch Error "Unfortunately 'app' has stopped working"

From Dev

Unfortunately, my application has stopped

From Dev

Android : Unfortunately, app has stopped

From Dev

Unfortunately,"App" has stopped, OnClickListener

From Dev

Unfortunately,"App" has stopped, OnClickListener

From Dev

Alternative of 'unfortunately app has stopped'

From Dev

android app unfortunately has stopped

From Dev

Android Studio error: Unfortunately My Own App has stopped

From Dev

"Unfortunately, App name has stopped" Simple app

From Dev

Android App Unfortunately App has stopped

From Dev

Android SQL app unfortunately app has stopped

From Dev

Android: Unfortunately (project name) has stopped working

From Dev

my application keeps receiving "Unfortunately "My App" has stopped" after Running the app

From Dev

Android Emulator: Unfortunately App has stopped

From Dev

Unfortunately App has stopped , with zero errors

Related Related

HotTag

Archive