不幸的是我的应用已停止工作

瓦比

这是我的登录活动类,我想在登录后登录并显示地图,但是当我运行该应用程序时,它显示不幸的是停止了登录

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();
    }
}

这是在日志猫中显示的错误代码

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>
皮尤什

<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>

<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" />

这是因为您的</ TextView>在片段类之后关闭了,所以出现了此错误。

在这里也改变

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

以及您的LoginSuccess活动中

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

这意味着您必须在清单文件中声明此部分。

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

并且必须使用最新的Google Play服务。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Android:不幸的是(项目名称)已停止工作

来自分类Dev

不幸的是,应用已停止工作?

来自分类Dev

我的第一个应用已停止工作错误

来自分类Dev

应用已停止工作,但日志未显示错误?

来自分类Dev

不幸的是,应用已停止,错误为零

来自分类Dev

Xamarin.Forms在Android上“应用已停止工作”

来自分类Dev

Xamarin Android应用程序不幸地停止工作

来自分类Dev

Android的工作室:不幸的是“我的应用”已停止

来自分类Dev

登录后,显示“不幸的是,应用已停止”

来自分类Dev

由于NFC权限,可能“不幸的是MyAPP已停止工作”

来自分类Dev

我的Google Chrome扩展程序已全部停止工作

来自分类Dev

应用程序已停止工作

来自分类Dev

不幸的是,应用程序已停止工作?

来自分类Dev

不幸的是,我的应用已停止(我在android中的第一个应用)

来自分类Dev

不幸的是,该应用程序在Android中已停止工作错误

来自分类Dev

不幸的是,您的“ APP”已停止工作

来自分类Dev

不幸的是,myapp已停止工作

来自分类Dev

正在构建Google Maps API v2应用程序,但不幸的是.apk已停止工作

来自分类Dev

提交我的应用程序后,iAds已停止工作

来自分类Dev

不幸的是,该应用已停止工作

来自分类Dev

Sendmail已停止工作

来自分类Dev

不幸的是,Android应用已停止

来自分类Dev

不幸的是我的应用已停止

来自分类Dev

不幸的是,MyApp已停止工作

来自分类Dev

每当我在模拟器上运行该应用程序时,它都会说不幸的是,该应用程序已停止工作,日志显示如下

来自分类Dev

Android Studio:如何调试在模拟器中显示错误“不幸的是,应用程序已停止工作”的Android应用程序?

来自分类Dev

不幸的是,我的申请已停止

来自分类Dev

当我按下 ButtonImage 时应用程序崩溃。不幸的是,该应用程序已停止工作

来自分类Dev

是否可以从“不幸的应用程序已停止工作”错误中获取额外信息?

Related 相关文章

  1. 1

    Android:不幸的是(项目名称)已停止工作

  2. 2

    不幸的是,应用已停止工作?

  3. 3

    我的第一个应用已停止工作错误

  4. 4

    应用已停止工作,但日志未显示错误?

  5. 5

    不幸的是,应用已停止,错误为零

  6. 6

    Xamarin.Forms在Android上“应用已停止工作”

  7. 7

    Xamarin Android应用程序不幸地停止工作

  8. 8

    Android的工作室:不幸的是“我的应用”已停止

  9. 9

    登录后,显示“不幸的是,应用已停止”

  10. 10

    由于NFC权限,可能“不幸的是MyAPP已停止工作”

  11. 11

    我的Google Chrome扩展程序已全部停止工作

  12. 12

    应用程序已停止工作

  13. 13

    不幸的是,应用程序已停止工作?

  14. 14

    不幸的是,我的应用已停止(我在android中的第一个应用)

  15. 15

    不幸的是,该应用程序在Android中已停止工作错误

  16. 16

    不幸的是,您的“ APP”已停止工作

  17. 17

    不幸的是,myapp已停止工作

  18. 18

    正在构建Google Maps API v2应用程序,但不幸的是.apk已停止工作

  19. 19

    提交我的应用程序后,iAds已停止工作

  20. 20

    不幸的是,该应用已停止工作

  21. 21

    Sendmail已停止工作

  22. 22

    不幸的是,Android应用已停止

  23. 23

    不幸的是我的应用已停止

  24. 24

    不幸的是,MyApp已停止工作

  25. 25

    每当我在模拟器上运行该应用程序时,它都会说不幸的是,该应用程序已停止工作,日志显示如下

  26. 26

    Android Studio:如何调试在模拟器中显示错误“不幸的是,应用程序已停止工作”的Android应用程序?

  27. 27

    不幸的是,我的申请已停止

  28. 28

    当我按下 ButtonImage 时应用程序崩溃。不幸的是,该应用程序已停止工作

  29. 29

    是否可以从“不幸的应用程序已停止工作”错误中获取额外信息?

热门标签

归档