实际上,我已经开发了我的 Android 应用程序版本 10(2.33),但我发现了一个问题,当我在移动设备上运行应用程序时它工作正常,但一段时间后移动设备进入睡眠模式并且当我启用或解锁设备然后观察当设备的方向改变时,该应用程序显示由用户填充的内容被清除并且内容恢复。先生,请在这方面帮助我,谢谢。我还绑定了 onCretae 方法的源代码。
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); 尝试{
setContentView(R.layout.main);
ListView lstMain = (ListView) findViewById(R.id.lstMain);
btnSetting =(Button)findViewById(R.id.btnSetting);
btnCheck = (Button)findViewById(R.id.btnCheckStatus);
btnabout = (Button)findViewById(R.id.btnabout);
imgUserAdmin = (ImageView)findViewById(R.id.imgUserAdmin);
btnCheck.setOnClickListener(buttonhandler);
btnSetting.setOnClickListener(buttonhandler);
btnExit = (Button)findViewById(R.id.btnExit);
btnLocation = (Button)findViewById(R.id.btnAddSelLocation);
btnLocation.setOnClickListener(buttonhandler);
btnExit.setOnClickListener(buttonhandler);
startService(new Intent(this,SmsService.class));
IntentFilter filter = new IntentFilter(ConstantClass.SMS_RECEIVED);
registerReceiver(smsSend.sms_send,smsSend.getSentIntentFilter());
registerReceiver(smsSend.sms_delivered,smsSend.getDeliveredFilter());
registerReceiver(receivedSms,filter);
lstMain.setOnItemClickListener(lstMainClick);
dba.Open();
String str = "SELECT " + DataBaseAdapter.Key_UserID + " FROM " + ConstantClass.dbName[0] + " WHERE " +
DataBaseAdapter.Key_MBID + " = ?";
id = dba.CurrentWorkingCoordinator(DataBaseAdapter.Key_SendCoord, 1);
if(!Integer.toString(id).equals(ConstantClass.isCrdDiffer))
ConstantClass.isAuditrequestSend=true;
if(ConstantClass.isAuditrequestSend==false)
btnCheck.setText("Checking..");
String c = null;
if(id!=0){
Cursor admin =dba.ExecuteSelect(str, id);
if (admin!=null)
admin.moveToFirst();
if(admin.getCount()>0){
c = admin.getString(admin.getColumnIndex(DataBaseAdapter.Key_UserID));
if(c.equals("A")){
ConstantClass.has_authority = "A";
imgUserAdmin.setImageResource(R.drawable.admin);
}else
imgUserAdmin.setImageResource(R.drawable.admingreen);
}
if(ConstantClass.SelectCord.equals("All")){
btnCheck.setEnabled(false);
btnSetting.setEnabled(false);
String dev="000000";
curMain = dba.SelectDeviceOnId(DataBaseAdapter.Key_DevID, dev);
/*cursor = dba.getCoord(1);
if (cursor.getCount()>0){
cursor.moveToFirst();
ConstantClass.address = cursor.getString(cursor.getColumnIndex(DataBaseAdapter.Key_MbNo)).toString();
}*/
startManagingCursor(curMain);
if(curMain.getCount()>0){
curMain.moveToFirst();
adpt = new customCursorAdapter(this,curMain);
lstMain.setAdapter(adpt);
}
}else{
curMain = dba.SelFromDeviceStorage(DataBaseAdapter.Key_DevCoordId,id);
cursor = dba.getCoord(1);
if (cursor.getCount()>0){
cursor.moveToFirst();
ConstantClass.address = cursor.getString(cursor.getColumnIndex(DataBaseAdapter.Key_MbNo)).toString();
}
startManagingCursor(curMain);
if(curMain.getCount()>0){
curMain.moveToFirst();
adpt = new customCursorAdapter(this,curMain);
lstMain.setAdapter(adpt);
}
}
}
}catch(Exception ex){
dlg = new ExceptionDialog(this,"Zigbee Activity",ex.getMessage());
dlg.show();
}
}