Форум программистов, компьютерный форум CyberForum.ru

Программирование Android

Войти
Регистрация
Восстановить пароль
 
Jat
1 / 1 / 0
Регистрация: 12.02.2013
Сообщений: 22
#1

Ошибка при выходе из активности - Android

22.10.2013, 14:02. Просмотров 518. Ответов 0
Метки нет (Все метки)

Доброго времени суток.
Возникла такая проблема: при вызове второй активности создается список из уже существующей базы данных. Если нажать кнопку "назад" на эмуляторе андроид приложение уходит в ошибку. При этом выполняется методы из onCreate. Посмотрите плиз может кто поможет:
Вот первая активность:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.example.caloric;
 
import java.util.ArrayList;
 
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
 
public class MainActivity extends ListActivity {
    private static final String DB_NAME = "Caloric"; //имя нашей базы данных
 
    private static final String TABLE_PRODUCT_GROUP = "ProductGroup"; //таблица групп продуктов
    private static final String PRODUCT_GROUP_ID = "_id";
    private static final String PRODUCT_GROUP_NAME = "GroupName";
    
    private static final String TABLE_PRODUCTS = "Products"; // таблица продуктов
    private static final String PRODUCTS_ID = "_id";
    private static final String PRODUCTS_NAME = "PName";
    private static final String PRODUCTS_PROTEIN = "Protein";
    private static final String PRODUCTS_FAT = "Fat";
    private static final String PRODUCTS_CARBOHYDRATE = "Carbohydrate";
    private static final String PRODUCTS_KCAL = "Kcal";
    private static final String PRODUCTS_PID = "PID";
 
    final String LOG_TAG = "myLogs";
    
    private SQLiteDatabase database;
    private ListView listView;
    private ArrayList productGroup; // список групп продуктов
    private ArrayList products; // список продуктов
    private ArrayList productA; //выборка из продуктов
    private ArrayList selectList; //выбор для теста
    TextView tvView; // переменная для отображения TextView
    public String PID; //переменнка пока не знаю куда пригодится
    
    String selection;
    String[] selectionArgs;
    String[] selrctList = null;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        OpenBase dbOpenHelper = new OpenBase(this, DB_NAME);
        database = dbOpenHelper.openDataBase(); //открываем базу данных
        fillProductGroup();
        fillProducts();
        //fillProductA(PID);
        setUpList();
        tvView = (TextView)findViewById(R.id.TextView2);
        
    }
 
private void setUpList() {
 
    setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, productGroup));
    listView = getListView();
 
    listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View view,
                        int position,long id) {
            Toast.makeText(getApplicationContext(),
                    "Вы выбрали: " +
            ((TextView) view).getText(),
                         Toast.LENGTH_SHORT).show();
            tvView.setText(((TextView)view).getText());
            PID = tvView.getText().toString();
            Log.d(LOG_TAG, "PID " + PID);
            //fillProductA(PID);
            Intent intent = new Intent(MainActivity.this, ProductsActivity.class);
            startActivity(intent);
            
            intent.putExtra("tvView", tvView.getText().toString()); // в ключ username пихаем текст из первого текстового поля
            startActivity(intent);
            
        }
        
    });
    
}
 
 
//Извлечение элементов из базы данных ProductGroup
private void fillProductGroup() {
    productGroup = new ArrayList<String>();
    Cursor productGroupCursor = database.query(TABLE_PRODUCT_GROUP,
                                             new String[] {PRODUCT_GROUP_ID, PRODUCT_GROUP_NAME},
                         null, null,null,null,
                                             PRODUCT_GROUP_NAME);
        productGroupCursor.moveToFirst();
        if(!productGroupCursor.isAfterLast()) {
            do {
                String name = productGroupCursor.getString(1);
                productGroup.add(name);
            } while (productGroupCursor.moveToNext());
        }
        productGroupCursor.close();
    }
 
private void fillProducts() {
    products = new ArrayList<String>();
    Cursor productsCursor = database.query(TABLE_PRODUCTS,
                                             new String[] {PRODUCTS_ID, PRODUCTS_NAME, PRODUCTS_PROTEIN,
                                        PRODUCTS_FAT, PRODUCTS_CARBOHYDRATE, PRODUCTS_KCAL, PRODUCTS_PID},
                         null, null,null,null,
                                            PRODUCTS_NAME);
        productsCursor.moveToFirst();
        if(!productsCursor.isAfterLast()) {
            do {
                String name = productsCursor.getString(1);
                products.add(name);
            } while (productsCursor.moveToNext());
        }
        productsCursor.close();
    }
}
Вот вторая:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
age com.example.caloric;
 
import java.util.ArrayList;
 
import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
 
public class ProductsActivity extends ListActivity{
    private static final String DB_NAME = "Caloric";
        
    private static final String TABLE_PRODUCT_GROUP = "ProductGroup"; //таблица групп продуктов
    private static final String PRODUCT_GROUP_ID = "_id";
    private static final String PRODUCT_GROUP_NAME = "GroupName";
    
    private static final String TABLE_PRODUCTS = "Products"; // таблица продуктов
    private static final String PRODUCTS_ID = "_id";
    private static final String PRODUCTS_NAME = "PName";
    private static final String PRODUCTS_PROTEIN = "Protein";
    private static final String PRODUCTS_FAT = "Fat";
    private static final String PRODUCTS_CARBOHYDRATE = "Carbohydrate";
    private static final String PRODUCTS_KCAL = "Kcal";
    private static final String PRODUCTS_PID = "PID";
    
    final String LOG_TAG = "myLogs";
    
    private SQLiteDatabase database;
    private ArrayList productA;
    private ArrayList product;
    private ListView listView;
    
    String selection;
    String[] selectionArgs;
    String[] selrctList = null;
    
    public String tvView;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.products);
       
        Log.d(LOG_TAG, "ВТОРАЯ");
 
        fillProductA(tvView);
    }
    
    private void setUpListTwo() {
 
        setListAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, product));
        listView = getListView();
 
    }
 
    private void fillProductA(String tvView){
        OpenBase dbOpenHelper = new OpenBase(this, DB_NAME);
        database = dbOpenHelper.openDataBase();
        
        tvView = getIntent().getExtras().getString("tvView");
        
        Log.d(LOG_TAG, "tvView " + tvView);
        productA = new ArrayList<String>();
        selection = "GroupName = ?";
        selectionArgs = new String[]{tvView};
        Cursor getProductGroupCursor = database.query(TABLE_PRODUCT_GROUP, null, selection, selectionArgs, null, null, null);
        getProductGroupCursor.moveToFirst();
        if(!getProductGroupCursor.isAfterLast()) {
            do {
                String name = getProductGroupCursor.getString(0);
                productA.add(name);
                Log.d(LOG_TAG, "Name " + name);
            } while (getProductGroupCursor.moveToNext());
        }
        getProductGroupCursor.close();
        String[] A = (String[]) productA.toArray(new String[productA.size()]); 
        //Log.d(LOG_TAG, "A " + A);
        String B = A[0];
        Log.d(LOG_TAG, "B " + B);
        
        product = new ArrayList<String>();
        selection = "PID = ?";
        selectionArgs = new String[]{B};
        Cursor getProductCursor = database.query(TABLE_PRODUCTS, null, selection, selectionArgs, null, null, null);
        getProductCursor.moveToFirst();
        if(!getProductCursor.isAfterLast()) {
            do {
                String name = getProductCursor.getString(1);
                product.add(name);
            } while (getProductCursor.moveToNext());
        }
        getProductCursor.close();
        setUpListTwo();
        
    }   
}
Собствнно ошибка при нажатии кнопки "Назад":

10-22 04:34:40.770: I/Database(332): sqlite returned: error code = 14, msg = cannot open file at source line 25467
10-22 04:34:40.770: E/Database(332): sqlite3_open_v2("//data//data//com.example.caloric//databases//Caloric", &handle, 1, NULL) failed
10-22 04:34:40.770: E/class com.example.caloric.OpenBase(332): Error while checking db
10-22 04:34:46.770: D/myLogs(332): PID Грибы
10-22 04:34:47.040: D/dalvikvm(332): GC_EXTERNAL_ALLOC freed 68K, 52% free 2610K/5379K, external 2064K/2137K, paused 121ms
10-22 04:34:47.060: E/Database(332): close() was never explicitly called on database '/data/data/com.example.caloric/databases/Caloric'
10-22 04:34:47.060: E/Database(332): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
10-22 04:34:47.060: E/Database(332): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:544)
10-22 04:34:47.060: E/Database(332): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
10-22 04:34:47.060: E/Database(332): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
10-22 04:34:47.060: E/Database(332): at com.example.caloric.OpenBase.createDataBase(OpenBase.java:41)
10-22 04:34:47.060: E/Database(332): at com.example.caloric.OpenBase.openDataBase(OpenBase.java:95)
10-22 04:34:47.060: E/Database(332): at com.example.caloric.OpenBase.<init>(OpenBase.java:34)
10-22 04:34:47.060: E/Database(332): at com.example.caloric.MainActivity.onCreate(MainActivity.java:55)
10-22 04:34:47.060: E/Database(332): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 04:34:47.060: E/Database(332): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 04:34:47.060: E/Database(332): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 04:34:47.060: E/Database(332): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 04:34:47.060: E/Database(332): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 04:34:47.060: E/Database(332): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 04:34:47.060: E/Database(332): at android.os.Looper.loop(Looper.java:123)
10-22 04:34:47.060: E/Database(332): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 04:34:47.060: E/Database(332): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 04:34:47.060: E/Database(332): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 04:34:47.060: E/Database(332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 04:34:47.060: E/Database(332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 04:34:47.060: E/Database(332): at dalvik.system.NativeStart.main(Native Method)
10-22 04:34:47.202: D/myLogs(332): ВТОРАЯ
10-22 04:34:47.230: I/class com.example.caloric.OpenBase(332): Database already exists
10-22 04:34:47.250: D/myLogs(332): tvView Грибы
10-22 04:34:47.250: D/myLogs(332): Name 1
10-22 04:34:47.270: D/myLogs(332): B 1
10-22 04:34:53.250: W/KeyCharacterMap(332): No keyboard for id 0
10-22 04:34:53.250: W/KeyCharacterMap(332): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-22 04:34:53.390: D/myLogs(332): ВТОРАЯ
10-22 04:34:53.400: I/class com.example.caloric.OpenBase(332): Database already exists
10-22 04:34:53.421: D/AndroidRuntime(332): Shutting down VM
10-22 04:34:53.421: W/dalvikvm(332): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-22 04:34:53.430: E/AndroidRuntime(332): FATAL EXCEPTION: main
10-22 04:34:53.430: E/AndroidRuntime(332): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.caloric/com.example.caloric.ProductsActivity}: java.lang.NullPointerException
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.os.Looper.loop(Looper.java:123)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 04:34:53.430: E/AndroidRuntime(332): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 04:34:53.430: E/AndroidRuntime(332): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 04:34:53.430: E/AndroidRuntime(332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 04:34:53.430: E/AndroidRuntime(332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 04:34:53.430: E/AndroidRuntime(332): at dalvik.system.NativeStart.main(Native Method)
10-22 04:34:53.430: E/AndroidRuntime(332): Caused by: java.lang.NullPointerException
10-22 04:34:53.430: E/AndroidRuntime(332): at com.example.caloric.ProductsActivity.fillProductA(ProductsActivity.java:74)
10-22 04:34:53.430: E/AndroidRuntime(332): at com.example.caloric.ProductsActivity.onCreate(ProductsActivity.java:58)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 04:34:53.430: E/AndroidRuntime(332): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 04:34:53.430: E/AndroidRuntime(332): ... 11 more
10-22 04:37:33.950: I/class com.example.caloric.OpenBase(444): Database already exists
10-22 04:37:39.570: D/myLogs(444): PID Грибы
10-22 04:37:39.770: D/dalvikvm(444): GC_EXTERNAL_ALLOC freed 71K, 52% free 2608K/5379K, external 2064K/2137K, paused 61ms
10-22 04:37:39.840: D/myLogs(444): ВТОРАЯ
10-22 04:37:39.850: I/class com.example.caloric.OpenBase(444): Database already exists
10-22 04:37:39.870: D/myLogs(444): tvView Грибы
10-22 04:37:39.870: D/myLogs(444): Name 1
10-22 04:37:39.870: D/myLogs(444): B 1
10-22 04:37:42.800: W/KeyCharacterMap(444): No keyboard for id 0
10-22 04:37:42.800: W/KeyCharacterMap(444): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-22 04:37:42.920: D/myLogs(444): ВТОРАЯ
10-22 04:37:42.931: I/class com.example.caloric.OpenBase(444): Database already exists
10-22 04:37:42.950: D/AndroidRuntime(444): Shutting down VM
10-22 04:37:42.950: W/dalvikvm(444): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-22 04:37:42.960: E/AndroidRuntime(444): FATAL EXCEPTION: main
10-22 04:37:42.960: E/AndroidRuntime(444): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.caloric/com.example.caloric.ProductsActivity}: java.lang.NullPointerException
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.os.Looper.loop(Looper.java:123)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 04:37:42.960: E/AndroidRuntime(444): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 04:37:42.960: E/AndroidRuntime(444): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 04:37:42.960: E/AndroidRuntime(444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 04:37:42.960: E/AndroidRuntime(444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 04:37:42.960: E/AndroidRuntime(444): at dalvik.system.NativeStart.main(Native Method)
10-22 04:37:42.960: E/AndroidRuntime(444): Caused by: java.lang.NullPointerException
10-22 04:37:42.960: E/AndroidRuntime(444): at com.example.caloric.ProductsActivity.fillProductA(ProductsActivity.java:74)
10-22 04:37:42.960: E/AndroidRuntime(444): at com.example.caloric.ProductsActivity.onCreate(ProductsActivity.java:58)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 04:37:42.960: E/AndroidRuntime(444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 04:37:42.960: E/AndroidRuntime(444): ... 11 more
10-22 04:37:44.480: I/Process(444): Sending signal. PID: 444 SIG: 9
10-22 04:40:30.050: I/class com.example.caloric.OpenBase(479): Database already exists
10-22 04:40:34.820: D/myLogs(479): PID Грибы
10-22 04:40:34.981: D/dalvikvm(479): GC_EXTERNAL_ALLOC freed 61K, 52% free 2608K/5379K, external 2064K/2137K, paused 62ms
10-22 04:40:35.060: D/myLogs(479): ВТОРАЯ
10-22 04:40:35.070: I/class com.example.caloric.OpenBase(479): Database already exists
10-22 04:40:35.083: D/myLogs(479): tvView Грибы
10-22 04:40:35.090: D/myLogs(479): Name 1
10-22 04:40:35.090: D/myLogs(479): B 1
10-22 04:40:38.732: W/KeyCharacterMap(479): No keyboard for id 0
10-22 04:40:38.732: W/KeyCharacterMap(479): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-22 04:40:38.842: D/myLogs(479): ВТОРАЯ
10-22 04:40:38.860: I/class com.example.caloric.OpenBase(479): Database already exists
10-22 04:40:38.870: D/AndroidRuntime(479): Shutting down VM
10-22 04:40:38.870: W/dalvikvm(479): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-22 04:40:38.890: E/AndroidRuntime(479): FATAL EXCEPTION: main
10-22 04:40:38.890: E/AndroidRuntime(479): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.caloric/com.example.caloric.ProductsActivity}: java.lang.NullPointerException
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.os.Looper.loop(Looper.java:123)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 04:40:38.890: E/AndroidRuntime(479): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 04:40:38.890: E/AndroidRuntime(479): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 04:40:38.890: E/AndroidRuntime(479): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 04:40:38.890: E/AndroidRuntime(479): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 04:40:38.890: E/AndroidRuntime(479): at dalvik.system.NativeStart.main(Native Method)
10-22 04:40:38.890: E/AndroidRuntime(479): Caused by: java.lang.NullPointerException
10-22 04:40:38.890: E/AndroidRuntime(479): at com.example.caloric.ProductsActivity.fillProductA(ProductsActivity.java:70)
10-22 04:40:38.890: E/AndroidRuntime(479): at com.example.caloric.ProductsActivity.onCreate(ProductsActivity.java:55)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 04:40:38.890: E/AndroidRuntime(479): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 04:40:38.890: E/AndroidRuntime(479): ... 11 more
10-22 04:40:40.590: I/Process(479): Sending signal. PID: 479 SIG: 9
10-22 04:51:42.200: I/class com.example.caloric.OpenBase(512): Database already exists
10-22 04:51:47.620: D/myLogs(512): PID Грибы
10-22 04:51:47.790: D/dalvikvm(512): GC_EXTERNAL_ALLOC freed 62K, 52% free 2608K/5379K, external 2064K/2137K, paused 61ms
10-22 04:51:47.870: D/myLogs(512): ВТОРАЯ
10-22 04:51:47.891: I/class com.example.caloric.OpenBase(512): Database already exists
10-22 04:51:47.900: D/myLogs(512): tvView Грибы
10-22 04:51:47.910: D/myLogs(512): Name 1
10-22 04:51:47.910: D/myLogs(512): B 1
10-22 04:51:55.570: W/KeyCharacterMap(512): No keyboard for id 0
10-22 04:51:55.570: W/KeyCharacterMap(512): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-22 04:51:55.690: D/myLogs(512): ВТОРАЯ
10-22 04:51:55.700: I/class com.example.caloric.OpenBase(512): Database already exists
10-22 04:51:55.721: D/AndroidRuntime(512): Shutting down VM
10-22 04:51:55.721: W/dalvikvm(512): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-22 04:51:55.730: E/AndroidRuntime(512): FATAL EXCEPTION: main
10-22 04:51:55.730: E/AndroidRuntime(512): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.caloric/com.example.caloric.ProductsActivity}: java.lang.NullPointerException
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.os.Looper.loop(Looper.java:123)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 04:51:55.730: E/AndroidRuntime(512): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 04:51:55.730: E/AndroidRuntime(512): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 04:51:55.730: E/AndroidRuntime(512): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 04:51:55.730: E/AndroidRuntime(512): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 04:51:55.730: E/AndroidRuntime(512): at dalvik.system.NativeStart.main(Native Method)
10-22 04:51:55.730: E/AndroidRuntime(512): Caused by: java.lang.NullPointerException
10-22 04:51:55.730: E/AndroidRuntime(512): at com.example.caloric.ProductsActivity.fillProductA(ProductsActivity.java:70)
10-22 04:51:55.730: E/AndroidRuntime(512): at com.example.caloric.ProductsActivity.onCreate(ProductsActivity.java:55)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 04:51:55.730: E/AndroidRuntime(512): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 04:51:55.730: E/AndroidRuntime(512): ... 11 more

Добавлено через 5 часов 8 минут
Все, проблема решена.
Все как обычно банально тупо.
Оказывается в первом классе два вызова второй активности.
Similar
Эксперт
41792 / 34177 / 6122
Регистрация: 12.04.2006
Сообщений: 57,940
22.10.2013, 14:02     Ошибка при выходе из активности
Посмотрите здесь:

Android Краш при создании активности
NullPointerException в дополнительной активности Android
Android Как сделать так, чтобы при выходе из программы она продолжала работать? (не вирус)
Android Запуск активности из фрагмента
Автоматическое запоминание позиции при выходе из приложения Android
Обновление списка при выходе из DialogFragment Android
Уведомление пользователя при выходе из приложения Android
Android Диалог ожидания при запуске активности
Действие при сворачивании или при выходе Android
Android Убрать уведомление при выходе из приложения
Android Отслеживание активности
Android Остановить сервис при выходе из приложения

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
После регистрации реклама в сообщениях будет скрыта и будут доступны все возможности форума.
Ответ Создать тему
Опции темы

Текущее время: 17:56. Часовой пояс GMT +3.
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Рейтинг@Mail.ru