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 | } |