Android: thread beenden mit Ausnahme uncaught (Gruppe=0xb0f03648).nullpointerexception

Ich bin neu in android-Programmierung. Ich versuchte, führen Sie eine einfache app, die aus einem der tutorials und es zeigt runtime error. Ich sehe in der Konsole Meldungen, dass es schon installiert, aber beim starten, es wirft den Fehler. Ich Kreuz überprüft die Einträge in der manifest-Datei mit dem aktuellen Dateinamen. Sie alle sehen gut aus. Unten sind die Fehlermeldungen von logcat und die Aktivität Datei. Dankbar für Ihre Hilfe. Vielen Dank im Voraus.

Logcat Meldungen

01-02 19:54:17.179: D/AndroidRuntime(3088): Shutting down VM
01-02 19:54:17.179: W/dalvikvm(3088): threadid=1: thread exiting with uncaught exception (group=0xb0f03648)
01-02 19:54:17.239: E/AndroidRuntime(3088): FATAL EXCEPTION: main
01-02 19:54:17.239: E/AndroidRuntime(3088): java.lang.RuntimeException: Unable to start activity ComponentInfo    {com.vogella.android.intent.implicit/com.vogella.android.intent.implicit.CallIntentsActivity}: java.lang.NullPointerException
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread.performLaunchActivity    (ActivityThread.java:2211)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread.handleLaunchActivity    (ActivityThread.java:2261)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.os.Looper.loop(Looper.java:137)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread.main(ActivityThread.java:5103)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at java.lang.reflect.Method.invokeNative(Native Method)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at java.lang.reflect.Method.invoke(Method.java:525)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run    (ZygoteInit.java:737)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at dalvik.system.NativeStart.main(Native Method)
01-02 19:54:17.239: E/AndroidRuntime(3088): Caused by: java.lang.NullPointerException
01-02 19:54:17.239: E/AndroidRuntime(3088):     at com.vogella.android.intent.implicit.CallIntentsActivity.onCreate    (CallIntentsActivity.java:24)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.Activity.performCreate(Activity.java:5133)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.Instrumentation.callActivityOnCreate    (Instrumentation.java:1087)
01-02 19:54:17.239: E/AndroidRuntime(3088):     at android.app.ActivityThread.performLaunchActivity    (ActivityThread.java:2175)
01-02 19:54:17.239: E/AndroidRuntime(3088):     ... 11 more

Unten ist die Aktivität code

package com.vogella.android.intent.implicit;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

public class CallIntentsActivity extends Activity {
    Spinner spinnr;
    public static final int URI_INTENT_SCHEME = 1;
    private static final int REQUEST_CODE = 10;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        spinnr = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.intents, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnr.setAdapter(adapter);
    }

    public void onClick(View view){
        int position = spinnr.getSelectedItemPosition();
        Intent call = null;
        switch(position){
        case 0:
            call = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.vogella.com"));
            break;
        case 1:
            call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:(+1)1234567899"));
            break;
        case 2:
            call = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:(+1)1234567888"));
            break;
        case 3:
            call = new Intent(Intent.ACTION_VIEW,Uri.parse("geo:50.123,7.1434?z=19"));
            break;
        case 4:
            call = new Intent(Intent.ACTION_VIEW,Uri.parse("geo:0,0?q=query"));
            break;
        case 5:
            call = new Intent("android.media.action.IMAGE_CAPTURE");
            break;
        case 6:
            call = new Intent(Intent.ACTION_VIEW,Uri.parse("content://contacts/people/"));
            break;
        case 7:
            call = new Intent(Intent.ACTION_EDIT,Uri.parse("content://contacts/people/1"));
            break;
        }
        if(call!= null){
            startActivity(call);
        }
    }

    public void onActivityResult(int resultCode, int requestCode, Intent data){
        if(resultCode == RESULT_OK && requestCode == REQUEST_CODE){
            String result = data.toUri(URI_INTENT_SCHEME);
            Toast.makeText(this, result, Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.call_intents, menu);
        return true;
    }

}

Unten ist die Androimanifest Datei:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vogella.android.intent.implicit"
    android:versionCode="1"
    android:versionName="1.0" >

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


    <uses-permission android:name="android.permission.CALL_PHONE" >
    </uses-permission>
    <uses-permission android:name="android.permission.CAMERA" >
    </uses-permission>
    <uses-permission android:name="android.permission.READ_CONTACTS" >
    </uses-permission>
    <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=".CallIntentsActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
  • keine root-anzeigen gefunden wird, müssen Sie setContentView() für root-Ansicht rechts unten super.onCreate()
InformationsquelleAutor user3155497 | 2014-01-03
Schreibe einen Kommentar