Sunday, February 16, 2014

Android Tablet Application Development process was plagued by problems for many days! Find Great God Weapon


The problem is this, the first landing from loginactivity page (let us call A), jump to the second page (let us call B), it will parse an XML document locally, and then the XML document is on page B listview in the display. A page when you press the Login button, the page will be successful jump to B, B page LISTVIEW data can occur. However, staying in B page about a second time (almost flashed), the program automatically jumps back to A and pages, then, if the press button A on the landing, the program automatically quit.

Here is the logcat the error message:

11-19 16:44:32.019: E / StrictMode (1601): A resource was acquired at attached stack trace but never released See java.io.Closeable for information on avoiding resource leaks
..11-19 16:44:32.019: E / StrictMode (1601): java.lang.Throwable: Explicit termination method 'close' not called
11-19 16:44:32.019: E / StrictMode (1601): at dalvik.system.CloseGuard.open (CloseGuard.java: 184)
11-19 16:44:32.019: E / StrictMode (1601): at java.io.FileInputStream . (FileInputStream.java: 80)
11-19 16:44:32.019: E / StrictMode (1601): at com.doctorstation.BLL.EntityService.setInputStream (EntityService.java: 46)
11-19 16:44:32.019: E / StrictMode (1601): at com.doctorstation.BLL.EntityService . (EntityService.java: 34)
11-19 16:44:32.019: E / StrictMode (1601): at com.doctorstation.UI.LoginActivity $ 1.onClick (LoginActivity.java: 130)
11-19 16:44:32.019: E / StrictMode (1601): at android.view.View.performClick (View.java: 3511)
11-19 16:44:32.019: E / StrictMode (1601): at android.view.View $ PerformClick.run (View.java: 14109)
11-19 16:44:32.019: E / StrictMode (1601): at android.os.Handler.handleCallback (Handler.java: 605)
11-19 16:44:32.019: E / StrictMode (1601): at android.os.Handler.dispatchMessage (Handler.java: 92)
11-19 16:44:32.019: E / StrictMode (1601): at android.os.Looper.loop (Looper.java: 137)
11-19 16:44:32.019: E / StrictMode (1601): at android.app.ActivityThread.main (ActivityThread.java: 4424)
11-19 16:44:32.019: E / StrictMode (1601): at java.lang.reflect.Method.invokeNative (Native Method)
11-19 16:44:32.019: E / StrictMode (1601): at java.lang.reflect.Method.invoke (Method.java: 511)
11-19 16:44:32.019: E / StrictMode (1601): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 784)
11-19 16:44:32.019: E / StrictMode (1601): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 551)
11-19 16:44:32.019: E / StrictMode (1601): at dalvik.system.NativeStart.main (Native Method)
11-19 16:44:32.019: W / System.err (1601): StrictMode VmPolicy violation with POLICY_DEATH; shutting down
.



Here is the source page B:

package com.doctorstation.UI;

import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.doctorstation.DAL.BasicInfo;
import com.doctorstation.DAL.PatMaster;
import com.doctorstation.BLL.DoctorXMLReader;
import com.doctorstation.BLL.EntityService;
import com.doctorstation.UI.R;

public class PatientMasterIndex extends Activity / * implements
OnItemClickListener, OnCheckedChangeListener * / {
String id;
String visit_id; / / wards
String dept_name;
String dept_code;
/ / Bed number
; String bed_noString pat_name;
String pat_sex;
String pat_birthday;
String pat_in;
String pat_out;
String nursing_class;
String DocName;
String DeptName;
CheckBox cb_notallpat;
private ListView patListView; / / declare listView type variable

SimpleAdapter ordersListItemAdapter;
List > ordersListItem = new ArrayList > ();
/ / String [] ordersKeys = new String [] {"BedNo", "Name", "Sex", "Birthday", "DateIn", "DateOut", "NursingClass"};
/ / Int [] ordersIds = new int [] {R.id.bednumber, R.id.patname, R.id.patsex, R.id.patbirth, R.id.patin, R.id.patout, R. id.nurclass};
@ Override

/ / String [] ordersKeys = new String [] {"doctor_order_lancher", "ItemTitle",
/ / "ItemText", "AdministrationCode", "Administration", "OrderStatus",
/ / "RepeatIndicator", "Paient_Id", "Visit_Id", "new_order"};

/ / Int [] ordersIds = new int []
/ / {R.id.patient_master_index2_sex_img, R.id.patient_master_index2_name, R.id.patient_master_index2_bed_no, R.id.patient_master_index2_administration_code, R.id.patient_master_index2_administration,
/ / R.id.patient_master_index2_order_status, R.id.patient_master_index2_repeat_indicator, R.id.patient_master_index2_patient_id,
/ / R.id.patient_master_index2_visit_id,
/ / R.id.patient_master_index2_is_new_img}; / / need to modify

public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
this.requestWindowFeature (Window.FEATURE_NO_TITLE);
setContentView (R.layout.patientmanagement);
patListView = (ListView) findViewById (R.id.patient_master_index_listview);
cb_notallpat = (CheckBox) findViewById (R.id.cb_notallpat);


Intent intent = this.getIntent (); / / get the existing intent object
Bundle bundle = intent.getExtras (); / / Get intent inside the bundle object
DocName = bundle.getString ("DocName"); / / get the string inside
BundleDeptName = bundle.getString ("DeptName");
TextView tv = (TextView) findViewById (R.id.textView2);
TextView tv1 = (TextView) findViewById (R.id.textView4);
tv.setText (DocName);
tv1.setText (DeptName);

ordersListItemAdapter = new SimpleAdapter (this, getorderListData (), / / ​​data source
R.layout.listviewitem, / / ​​ListItem XML implementation
new String [] {"BedNo", "Name", "Sex", "Birthday", "DateIn", "DateOut", "NursingClass"}, / / ​​dynamic array with the corresponding sub-item
ImageItemnew int [] {R.id.bednumber, R.id.patname, R.id.patsex, R.id.patbirth, R.id.patin, R.id.patout, R.id.nurclass}); < br />patListView.setAdapter (ordersListItemAdapter);

}
public List > getorderListData () {
DoctorXMLReader dxr = new DoctorXMLReader ("basic_info.xml") ;/ / parse a local XML file, here DoctorXMLReader PULL parsing XML-based method
List allBI;
try {
allBI = dxr.getBasicInfo ();

for (BasicInfo bi: allBI)
{
/ / For (int i = 0; i Map map = new HashMap ();
/ / "BedNo", "Name", "Sex", "Birthday", "DateIn", "DateOut", "NursingClass"
map.put ("BedNo", bi.gete ());
map.put ("Name", bi.getg ());
map.put ("Sex", bi.geti ());
map.put ("Birthday", bi.getj ());
map.put ("DateIn", bi.geto ());
map.put ("DateOut", bi.getp ());
map.put ("NursingClass", bi.getr ());
ordersListItem.add (map);
}
}
catch (Exception e) {
e.printStackTrace ();
}
return ordersListItem;
}

}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Resource problems when reading and writing,
11-19 16:44:32.019: E / StrictMode (1601): java.lang.Throwable: Explicit termination method 'close' not called
11-19 16:44:32.019: E / StrictMode (1601): at dalvik.system.CloseGuard.open (CloseGuard.java: 184)

This means that the method does not display the call close to release resources.
Reply:
First, you give the landlord the source file is wrong, it should be EntityService this class file. com.doctorstation.BLL.EntityService.setInputStream (EntityService.java: 46)

You see, the FileInputStream object of this document does not call close () method to close the file input stream, or due to try catch statement in case of errors that occur skipped cloase () function call.

Reply:
cited a floor birdsaction reply:
resources when reading and writing problems,
11-19 16:44:32.019: E / StrictMode (1601): java.lang.Throwable: Explicit termination method 'close' not called
11-19 16:44:32.019: E / StrictMode (1601): at dalvik.system.CloseGuard.open (CloseGuard.java: 184)

This means that the method does not display the call close to release resources.

Thank you very much! Have found the problem!
Reply:
reference to the second floor ncepu307 reply:
First you give the landlord the right source files should be EntityService this class file. com.doctorstation.BLL.EntityService.setInputStream (EntityService.java: 46)

You see, the FileInputStream object of this document does not call close () method to close the file input stream, or due to try catch statement in case of errors that occur skipped cloase () function call.

Thank you very much! Xueyibujing is the younger brother, had found the problem!

No comments:

Post a Comment