View difference between Paste ID: SSicFHee and hTQnQdda
SHOW: | | - or go back to the newest paste.
1
//  The problem that I am having is when I call a QRCODE scan from a fragment, the app crashes when it returns to the fragment.  It scans perfectly well, but I think the problem lies at:
2
//****************   this is where I think the problem is....  
3
    @Override
4
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
5
 have this same code running from another app with an activity and only two fragments. 
6
I would try to run this in an emulator, but Emulators don't have cams.
7
//==============================================================================
8
9
//============   I am also having trouble getting the stack trace from log cat.
10
11
DeviceMonitor: Failed to start monitoring 0146B56616013011
12
DeviceMonitor: Adb rejected command to get  device 0146B56616013011 info: device unauthorized. Please check the confirmation dialog on your device.
13
DeviceMonitor: IO Error getting info for device 0146B56616013011
14
DeviceMonitor: Failed to start monitoring 0146B56616013011
15
DeviceMonitor: Adb rejected command to get  device 0146B56616013011 info: device unauthorized. Please check the confirmation dialog on your device.
16
DeviceMonitor: IO Error getting info for device 0146B56616013011
17
DeviceMonitor: IO Error getting info for device 0146B56616013011
18
DeviceMonitor: Adb rejected command to get  device 0146B56616013011 info: device not found
19
20
21
22
//==================
23
24
package com.techlatin.loge;
25
26
import android.content.Context;
27
import android.content.Intent;
28
import android.graphics.Color;
29
import android.location.Location;
30
import android.location.LocationListener;
31
import android.location.LocationManager;
32
import android.support.v7.app.ActionBarActivity;
33
import android.support.v7.app.ActionBar;
34
import android.support.v4.app.Fragment;
35
import android.os.Bundle;
36
import android.view.LayoutInflater;
37
import android.view.Menu;
38
import android.view.MenuItem;
39
import android.view.View;
40
import android.view.ViewGroup;
41
import android.os.Build;
42
import android.widget.Button;
43
import android.widget.TextView;
44
45
public class ZZE_NewLocations extends ActionBarActivity {
46
47
    String session_id;
48
    String session_name;
49
50
    String Lat;
51
    String Lng;
52
    String zzBINIDQR;
53
54
    String ErrorText;
55
    Boolean thereWasAnError = false;
56
57
58
59
    @Override
60
    protected void onCreate(Bundle savedInstanceState) {
61
        super.onCreate(savedInstanceState);
62
        setContentView(R.layout.activity_zze__new_locations);
63
64
        if (savedInstanceState == null) {
65
            getSupportFragmentManager().beginTransaction()
66
                    .add(R.id.container, new PlaceholderFragment())
67
                    .commit();
68
        }
69
    }
70
71
72
    @Override
73
    public boolean onCreateOptionsMenu(Menu menu) {
74
        
75
        // Inflate the menu; this adds items to the action bar if it is present.
76
        getMenuInflater().inflate(R.menu.zze__new_locations, menu);
77
        return true;
78
    }
79
80
    @Override
81
    public boolean onOptionsItemSelected(MenuItem item) {
82
        // Handle action bar item clicks here. The action bar will
83
        // automatically handle clicks on the Home/Up button, so long
84
        // as you specify a parent activity in AndroidManifest.xml.
85
        int id = item.getItemId();
86
        if (id == R.id.action_settings) {
87
            return true;
88
        }
89
        return super.onOptionsItemSelected(item);
90
    }
91
92
    /**
93
     * A placeholder fragment containing a simple view.
94
     */
95
    public static class PlaceholderFragment extends Fragment {
96
97
        public PlaceholderFragment() {
98
        }
99
100
        @Override
101
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
102
                Bundle savedInstanceState) {
103
            View rootView = inflater.inflate(R.layout.fragment_zze__new_locations, container, false);
104
            return rootView;
105
        }
106
    }
107
108
    //==========================================================
109
110
    private  boolean resumeHasRun = false;
111
    @Override
112
    protected void onResume(){
113
114
        //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
115
        //btnst01.setEnabled(false);
116
117
        super.onResume();
118
        if (!resumeHasRun){
119
            resumeHasRun = true;
120
            //return;
121
        }
122
        //  get the session stuff here
123
124
        Bundle extras = getIntent().getExtras();
125
        if (extras != null) {
126
            session_id = extras.getString("session_id");
127
            session_name = extras.getString("session_name");
128
129
            final TextView xxSESSION_NAME = (TextView) findViewById(R.id.tvSESSION_NAME01);
130
            xxSESSION_NAME.setText(session_name);
131
132
            final TextView xxSESSION_ID = (TextView) findViewById(R.id.tvSESSION_ICD01);
133
            xxSESSION_ID.setText(session_id);
134
135
        }
136
137
        Do_WHATABOUT_ZZE();
138
139
    }
140
141
    private void Do_WHATABOUT_ZZE(){
142
        //  will explain what this screen is about
143
        TextView tv_zze_WhatAbout = (TextView) findViewById(R.id.tv_ZZE_WHAT_ABOUT);
144
        tv_zze_WhatAbout.setText("This screen is for NEW deployments of Existing and New Assets.  You should use this screen only ONCE per Asset.");
145
    }
146
147
148
149
   //================================================================
150
    //QRCode Reading
151
152
153
    public void btnZZZB_STEP01_SCAN01_click (View view){
154
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
155
        //intent.putExtra("SCAN_MODE", "PRODUCT_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
156
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
157
        intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
158
        startActivityForResult(intent, 0);
159
    }
160
161
162
//****************   this is where I think the problem is....  
163
    @Override
164
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
165
        super.onActivityResult(requestCode, resultCode, data);
166
        if (requestCode == 0) {
167
            if (resultCode == RESULT_OK) {
168
                //String contents =  data.getStringExtra("SCAN_RESULT"); //this is the result
169
170
             //   zzBINIDQR = data.getStringExtra("SCAN_RESULT");
171
172
173
             //   TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
174
             //   tvtest000.setText(BINID_QR);
175
             //   tvtest000.setBackgroundColor(Color.GREEN);
176
177
                //BINID_QR = contents;
178
179
                //Button btnst01a = (Button) findViewById(R.id.btnStep1_submit);
180
                //btnst01.setEnabled(true);
181
182
            }
183
            else if (resultCode == RESULT_CANCELED) {
184
                // Handle cancel
185
                //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
186
                //btnst01.setEnabled(false);
187
188
                zzBINIDQR = "---  no result ---";
189
190
191
             //   TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
192
             //   tvtest000.setText(BINID_QR);
193
             //   tvtest000.setBackgroundColor(Color.RED);
194
195
            }
196
        }
197
    }
198
199
200
201
//========================  FRAGMENTS  ===============================
202
    public void btnClick_zze_01__loc_id(View view){
203
204
        setContentView(R.layout.fragment_zze_01__loc_id);
205
206
    }
207
208
209
210
211
    //========================  FRAGMENTS  ===============================
212
    public void btnClick_zze_09__return(View view){
213
214
        setContentView(R.layout.fragment_zze__new_locations);
215
216
    }
217
218
219-
}
219+
}
220
221
222
//===========================  stack trace
223
12-27 01:07:22.686      803-803/? D/MtpService﹕ addStorageLocked 65537 /storage/emulated/0
224
12-27 01:07:23.240    5393-5393/? D/CaptureActivityHandler﹕ Got return scan result message
225
12-27 01:07:23.357     129-4222/? E/CameraHAL﹕ Adapter state switch PREVIEW_ACTIVE Invalid Op! event = 0xf
226
12-27 01:07:23.365     129-5420/? D/﹕ PPM: Focus finished in:  :1475.677 ms :  1388124443374 ms
227
12-27 01:07:23.584      129-429/? I/CameraClient﹕ Destroying camera 0
228
12-27 01:07:23.756      129-429/? W/AudioFlinger﹕ session id 93 not found for pid 129
229
12-27 01:07:23.764      129-429/? W/AudioFlinger﹕ session id 94 not found for pid 129
230
12-27 01:07:23.842      406-449/? I/InputReader﹕ Reconfiguring input devices.  changes=0x00000004
231
12-27 01:07:23.842      406-449/? I/InputReader﹕ Device reconfigured: id=6, name='Melfas MMSxxx Touchscreen', size 720x1280, orientation 0, mode 1, display id 0
232
12-27 01:07:23.850      406-864/? I/ActivityManager﹕ Config changes=1480 {1.0 310mcc4mnc en_US ldltr sw360dp w360dp h567dp 320dpi nrml port finger -keyb/v/h -nav/h s.24}
233
12-27 01:07:23.897    5365-5365/? D/AndroidRuntime﹕ Shutting down VM
234
12-27 01:07:23.897    5365-5365/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417d8930)
235
12-27 01:07:23.904    5365-5365/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
236
    java.lang.RuntimeException: Unable to resume activity {com.techlatin.loge/com.techlatin.loge.ZZE_NewLocations}: java.lang.NullPointerException
237
            at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
238
            at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
239
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276)
240
            at android.os.Handler.dispatchMessage(Handler.java:99)
241
            at android.os.Looper.loop(Looper.java:137)
242
            at android.app.ActivityThread.main(ActivityThread.java:5041)
243
            at java.lang.reflect.Method.invokeNative(Native Method)
244
            at java.lang.reflect.Method.invoke(Method.java:511)
245
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
246
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
247
            at dalvik.system.NativeStart.main(Native Method)
248
     Caused by: java.lang.NullPointerException
249
            at com.techlatin.loge.ZZE_NewLocations.onResume(ZZE_NewLocations.java:107)
250
            at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
251
            at android.app.Activity.performResume(Activity.java:5182)
252
            at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
253
            at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
254
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276)
255
            at android.os.Handler.dispatchMessage(Handler.java:99)
256
            at android.os.Looper.loop(Looper.java:137)
257
            at android.app.ActivityThread.main(ActivityThread.java:5041)
258
            at java.lang.reflect.Method.invokeNative(Native Method)
259
            at java.lang.reflect.Method.invoke(Method.java:511)
260
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
261
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
262
            at dalvik.system.NativeStart.main(Native Method)
263
12-27 01:07:23.936      406-771/? W/ActivityManager﹕ Force finishing activity com.techlatin.loge/.ZZE_NewLocations
264
12-27 01:07:23.943    5365-5367/? D/dalvikvm﹕ GC_CONCURRENT freed 183K, 3% free 9166K/9376K, paused 2ms+3ms, total 42ms
265
12-27 01:07:24.084      537-537/? W/PhoneStatusBar/NavigationBarView﹕ *** Invalid layout in navigation bar (sizeChanged this=720x96 cur=84x720)
266
12-27 01:07:24.436      406-419/? W/ActivityManager﹕ Activity pause timeout for ActivityRecord{42959f88 u0 com.techlatin.loge/.ZZE_NewLocations}
267
12-27 01:07:24.662      406-630/? D/dalvikvm﹕ GC_EXPLICIT freed 645K, 15% free 18210K/21416K, paused 4ms+12ms, total 103ms
268
12-27 01:07:24.717     803-5507/? D/dalvikvm﹕ GC_EXPLICIT freed 272K, 5% free 9231K/9716K, paused 2ms+5ms, total 30ms
269
12-27 01:07:26.162      406-421/? D/dalvikvm﹕ GC_EXPLICIT freed 72K, 16% free 18181K/21416K, paused 7ms+10ms, total 109ms
270
12-27 01:07:26.193      695-695/? D/DtMediaProvider﹕ onReceive: android.hardware.usb.action.USB_STATE