Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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:
- //**************** this is where I think the problem is....
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- have this same code running from another app with an activity and only two fragments.
- I would try to run this in an emulator, but Emulators don't have cams.
- //==============================================================================
- //============ I am also having trouble getting the stack trace from log cat.
- DeviceMonitor: Failed to start monitoring 0146B56616013011
- DeviceMonitor: Adb rejected command to get device 0146B56616013011 info: device unauthorized. Please check the confirmation dialog on your device.
- DeviceMonitor: IO Error getting info for device 0146B56616013011
- DeviceMonitor: Failed to start monitoring 0146B56616013011
- DeviceMonitor: Adb rejected command to get device 0146B56616013011 info: device unauthorized. Please check the confirmation dialog on your device.
- DeviceMonitor: IO Error getting info for device 0146B56616013011
- DeviceMonitor: IO Error getting info for device 0146B56616013011
- DeviceMonitor: Adb rejected command to get device 0146B56616013011 info: device not found
- //==================
- package com.techlatin.loge;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Color;
- import android.location.Location;
- import android.location.LocationListener;
- import android.location.LocationManager;
- import android.support.v7.app.ActionBarActivity;
- import android.support.v7.app.ActionBar;
- import android.support.v4.app.Fragment;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- import android.os.Build;
- import android.widget.Button;
- import android.widget.TextView;
- public class ZZE_NewLocations extends ActionBarActivity {
- String session_id;
- String session_name;
- String Lat;
- String Lng;
- String zzBINIDQR;
- String ErrorText;
- Boolean thereWasAnError = false;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_zze__new_locations);
- if (savedInstanceState == null) {
- getSupportFragmentManager().beginTransaction()
- .add(R.id.container, new PlaceholderFragment())
- .commit();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.zze__new_locations, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- /**
- * A placeholder fragment containing a simple view.
- */
- public static class PlaceholderFragment extends Fragment {
- public PlaceholderFragment() {
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_zze__new_locations, container, false);
- return rootView;
- }
- }
- //==========================================================
- private boolean resumeHasRun = false;
- @Override
- protected void onResume(){
- //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(false);
- super.onResume();
- if (!resumeHasRun){
- resumeHasRun = true;
- //return;
- }
- // get the session stuff here
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- session_id = extras.getString("session_id");
- session_name = extras.getString("session_name");
- final TextView xxSESSION_NAME = (TextView) findViewById(R.id.tvSESSION_NAME01);
- xxSESSION_NAME.setText(session_name);
- final TextView xxSESSION_ID = (TextView) findViewById(R.id.tvSESSION_ICD01);
- xxSESSION_ID.setText(session_id);
- }
- Do_WHATABOUT_ZZE();
- }
- private void Do_WHATABOUT_ZZE(){
- // will explain what this screen is about
- TextView tv_zze_WhatAbout = (TextView) findViewById(R.id.tv_ZZE_WHAT_ABOUT);
- tv_zze_WhatAbout.setText("This screen is for NEW deployments of Existing and New Assets. You should use this screen only ONCE per Asset.");
- }
- //================================================================
- //QRCode Reading
- public void btnZZZB_STEP01_SCAN01_click (View view){
- Intent intent = new Intent("com.google.zxing.client.android.SCAN");
- //intent.putExtra("SCAN_MODE", "PRODUCT_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
- intent.putExtra("SCAN_MODE", "QR_CODE_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
- intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
- startActivityForResult(intent, 0);
- }
- //**************** this is where I think the problem is....
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == 0) {
- if (resultCode == RESULT_OK) {
- //String contents = data.getStringExtra("SCAN_RESULT"); //this is the result
- // zzBINIDQR = data.getStringExtra("SCAN_RESULT");
- // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
- // tvtest000.setText(BINID_QR);
- // tvtest000.setBackgroundColor(Color.GREEN);
- //BINID_QR = contents;
- //Button btnst01a = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(true);
- }
- else if (resultCode == RESULT_CANCELED) {
- // Handle cancel
- //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
- //btnst01.setEnabled(false);
- zzBINIDQR = "--- no result ---";
- // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
- // tvtest000.setText(BINID_QR);
- // tvtest000.setBackgroundColor(Color.RED);
- }
- }
- }
- //======================== FRAGMENTS ===============================
- public void btnClick_zze_01__loc_id(View view){
- setContentView(R.layout.fragment_zze_01__loc_id);
- }
- //======================== FRAGMENTS ===============================
- public void btnClick_zze_09__return(View view){
- setContentView(R.layout.fragment_zze__new_locations);
- }
- }
- //=========================== stack trace
- 12-27 01:07:22.686 803-803/? D/MtpService﹕ addStorageLocked 65537 /storage/emulated/0
- 12-27 01:07:23.240 5393-5393/? D/CaptureActivityHandler﹕ Got return scan result message
- 12-27 01:07:23.357 129-4222/? E/CameraHAL﹕ Adapter state switch PREVIEW_ACTIVE Invalid Op! event = 0xf
- 12-27 01:07:23.365 129-5420/? D/﹕ PPM: Focus finished in: :1475.677 ms : 1388124443374 ms
- 12-27 01:07:23.584 129-429/? I/CameraClient﹕ Destroying camera 0
- 12-27 01:07:23.756 129-429/? W/AudioFlinger﹕ session id 93 not found for pid 129
- 12-27 01:07:23.764 129-429/? W/AudioFlinger﹕ session id 94 not found for pid 129
- 12-27 01:07:23.842 406-449/? I/InputReader﹕ Reconfiguring input devices. changes=0x00000004
- 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
- 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}
- 12-27 01:07:23.897 5365-5365/? D/AndroidRuntime﹕ Shutting down VM
- 12-27 01:07:23.897 5365-5365/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417d8930)
- 12-27 01:07:23.904 5365-5365/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
- java.lang.RuntimeException: Unable to resume activity {com.techlatin.loge/com.techlatin.loge.ZZE_NewLocations}: java.lang.NullPointerException
- at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
- at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276)
- at android.os.Handler.dispatchMessage(Handler.java:99)
- at android.os.Looper.loop(Looper.java:137)
- at android.app.ActivityThread.main(ActivityThread.java:5041)
- at java.lang.reflect.Method.invokeNative(Native Method)
- at java.lang.reflect.Method.invoke(Method.java:511)
- at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
- at dalvik.system.NativeStart.main(Native Method)
- Caused by: java.lang.NullPointerException
- at com.techlatin.loge.ZZE_NewLocations.onResume(ZZE_NewLocations.java:107)
- at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
- at android.app.Activity.performResume(Activity.java:5182)
- at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
- at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1276)
- at android.os.Handler.dispatchMessage(Handler.java:99)
- at android.os.Looper.loop(Looper.java:137)
- at android.app.ActivityThread.main(ActivityThread.java:5041)
- at java.lang.reflect.Method.invokeNative(Native Method)
- at java.lang.reflect.Method.invoke(Method.java:511)
- at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
- at dalvik.system.NativeStart.main(Native Method)
- 12-27 01:07:23.936 406-771/? W/ActivityManager﹕ Force finishing activity com.techlatin.loge/.ZZE_NewLocations
- 12-27 01:07:23.943 5365-5367/? D/dalvikvm﹕ GC_CONCURRENT freed 183K, 3% free 9166K/9376K, paused 2ms+3ms, total 42ms
- 12-27 01:07:24.084 537-537/? W/PhoneStatusBar/NavigationBarView﹕ *** Invalid layout in navigation bar (sizeChanged this=720x96 cur=84x720)
- 12-27 01:07:24.436 406-419/? W/ActivityManager﹕ Activity pause timeout for ActivityRecord{42959f88 u0 com.techlatin.loge/.ZZE_NewLocations}
- 12-27 01:07:24.662 406-630/? D/dalvikvm﹕ GC_EXPLICIT freed 645K, 15% free 18210K/21416K, paused 4ms+12ms, total 103ms
- 12-27 01:07:24.717 803-5507/? D/dalvikvm﹕ GC_EXPLICIT freed 272K, 5% free 9231K/9716K, paused 2ms+5ms, total 30ms
- 12-27 01:07:26.162 406-421/? D/dalvikvm﹕ GC_EXPLICIT freed 72K, 16% free 18181K/21416K, paused 7ms+10ms, total 109ms
- 12-27 01:07:26.193 695-695/? D/DtMediaProvider﹕ onReceive: android.hardware.usb.action.USB_STATE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement