0

ニューボストンのサイトで教えられているメール申し込みを完了しました。私がレビューした限りでは、すべてが順調です。私のアプリは問題なく動作しますが、を押すと"Send Email" Buttonアプリがクラッシュします。私は自分のアプリをテストしていHTC Desire Sます。これを手伝ってください。

私のマニフェストファイル:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>

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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TheNewBostonActivity"
        android:label="Add and Sub 1" >
        <intent-filter>
            <action android:name="com.thenewboston.pok.THENEWBOSTONACTIVITY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Menu"
        android:label="Select An Application" >
        <intent-filter>
            <action android:name="com.thenewboston.pok.MENU" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TextPlay"
        android:label="Text Play!" >          
    </activity>
    <activity
        android:name=".Email"
        android:label="Email Application" >
        <intent-filter>
            <action android:name="com.thenewboston.pok.EMAIL" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>          
    </activity>
    <activity
        android:name=".Camera"
        android:label="Camera Application"
        android:screenOrientation="portrait" >          
    </activity>
    <activity
        android:name=".Data"
        android:label="Rate It!!"
        android:screenOrientation="portrait" >          
    </activity> 
    <activity
        android:name=".OpenedClass"
        android:label="Rate It!!"
        android:screenOrientation="portrait" >          
    </activity>            

</application>

Email活動:

public class Email extends Activity implements View.OnClickListener{

EditText personsEmail, intro, personsName, stupidThings, hatefulAction, outro;
String emailAdd, beginning, name, stupidAction, hateAct, end;
Button sendEmail;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.email);
    initializeVars();
    sendEmail.setOnClickListener(this);

}

private void initializeVars() {
    // TODO Auto-generated method stub
    personsEmail = (EditText) findViewById(R.id.etEmails);
    stupidThings = (EditText) findViewById(R.id.etThings);
    intro = (EditText) findViewById(R.id.etIntro);
    personsName= (EditText) findViewById(R.id.etName);
    hatefulAction= (EditText) findViewById(R.id.etAction);
    sendEmail= (Button) findViewById(R.id.bSentEmail);
}

public void onClick(View v) {
    // TODO Auto-generated method stub
    convertEditToString();
    String emailAddress[] = {"emailAdd"};
    String message = "Well hello "
            + name
            + " I just wanted to say "
            + beginning
            + ".  Not only that but I hate when you "
            + stupidAction
            + ", that just really makes me crazy.  I just want to make you "
            + hateAct
            + ".  Welp, thats all I wanted to chit-chatter about, oh and "
            + end
            + ".  Oh also if you get bored you should check out www.mybringback.com"
            + '\n' + "PS. I think I love you...  :-(  ";

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailAddress);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello");
    emailIntent.setType("plain/text");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
    startActivity (emailIntent);

    }

    private void convertEditToString() {
        // TODO Auto-generated method stub
        emailAdd = personsEmail.getText().toString();
        beginning = intro.getText().toString();
        name = personsName.getText().toString();
        hateAct = hatefulAction.getText().toString();
        stupidAction = stupidThings.getText().toString();
        end = outro.getText().toString();
    }
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        finish();
    }

}

私のemail.xml

   <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:weightSum="100" android:layout_height="match_parent">
<ScrollView android:layout_weight="30" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout android:orientation="vertical"
        android:layout_width="match_parent" android:layout_height="match_parent">
        <TextView android:text="Email address(es):"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etEmails">
        </EditText>
        <TextView android:text="Hateful Intro:"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etIntro"></EditText>
        <TextView android:text="Person's name" android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etName"></EditText>
        <TextView android:text="Stupid Things that this Person does"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etThings"></EditText>
        <TextView android:text="What you want to do to this person:"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etAction"></EditText>
        <TextView android:text="Hateful Outro" android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etOutro"></EditText>
    </LinearLayout>
</ScrollView>
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent" android:layout_weight="40"
    android:layout_height="fill_parent">
    <Button android:text="Send Email" android:id="@+id/bSentEmail"
        android:layout_width="fill_parent" android:layout_height="fill_parent"></Button>
</LinearLayout>
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent" android:layout_weight="30"
    android:layout_height="fill_parent">
    <AnalogClock android:id="@+id/analogClock1"
        android:layout_width="fill_parent" android:layout_height="fill_parent"></AnalogClock>
</LinearLayout>

LogCatNullPointerException:_

10-02 22:15:40.603: E/AndroidRuntime(28009): FATAL EXCEPTION: main
10-02 22:15:40.603: E/AndroidRuntime(28009): java.lang.NullPointerException
10-02 22:15:40.603: E/AndroidRuntime(28009):    at com.thenewboston.pok.Email.convertEditToString(Email.java:69)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at com.thenewboston.pok.Email.onClick(Email.java:38)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.view.View.performClick(View.java:3549)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.view.View$PerformClick.run(View.java:14393)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.os.Handler.handleCallback(Handler.java:605)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.os.Looper.loop(Looper.java:154)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at android.app.ActivityThread.main(ActivityThread.java:4945)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at java.lang.reflect.Method.invokeNative(Native Method)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at java.lang.reflect.Method.invoke(Method.java:511)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-02 22:15:40.603: E/AndroidRuntime(28009):    at dalvik.system.NativeStart.main(Native Method)
4

1 に答える 1

0

その理由は、最後のものをidでNullPointerException初期化していないためです。メソッドに次の行を追加するだけです。EditTextetOutroinitializeVars

outro = (EditText) findViewById(R.id.etOutro);
于 2012-10-02T17:50:57.747 に答える