按钮正在进行错误的活动

时间:2014-07-07 16:03:16

标签: android android-intent

我有两个活动A (ChecksAndOperations)B (CaptureSignature)A点击ImageViewBImageView获得结果A细)。

但是,当我按下C (DatabaseLayout)中的按钮以获得结果后转到活动B,它会再次转到C,然后转到C。但我想直接转到A

B中的代码,用于打开结果

的活动case R.id.sigImg: { Intent goToCapSignatures = new Intent(this, CaptureSignature.class); startActivityForResult(goToCapSignatures, GET_SIG); }
OnActivityResult()
A中的{p> B来获取protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == GET_SIG) { if(resultCode == RESULT_OK) { if(data.hasExtra("signature")) { byte[] byteArray1 = data.getByteArrayExtra("signature"); Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray1 , 0, byteArray1.length); sigImg.setImageBitmap(bitmap); } } 的结果:

C

按钮代码(再次转到B再转到C,而不是直接转到String tick1_database_string = str_tickBtn1; String tick2_database_string=str_tickBtn2; String tick3_database_string=str_tickBtn3; String tick4_database_string=str_tickBtn4; String tick5_database_string=str_tickBtn5; String tick6_database_string=str_tickBtn6; String tick7_database_string=str_tickBtn7; String tick8_database_string=str_tickBtn8; String tick9_database_string=str_tickBtn9; String tick10_database_string=str_tickBtn10; String tick11_database_string=str_tickBtn11; String tick12_database_string=str_tickBtn12; String tick13_database_string=str_tickBtn13; String tick14_database_string=str_tickBtn14; String tick15_database_string=str_tickBtn15; String tick16_database_string=str_tickBtn16; String tick17_database_string=str_tickBtn17; String tick18_database_string = str_tickBtn18; String tick19_database_string = str_tickBtn19; String tick20_database_string = str_tickBtn20; String tick21_database_string = str_tickBtn21; String tick22_database_string = str_tickBtn22; str_appl_id = appliance_no.getText().toString(); str_appt_id = appointment_no.getText().toString(); str_recDate = dateDisplay.getText().toString(); str_tv_add_notes = showNotesFromNotesClass.getText().toString(); // pretty sure this code is creating logical error but not sure how BitmapDrawable drawable = (BitmapDrawable) sigImg.getDrawable(); Bitmap bitmap = drawable.getBitmap(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG,100,bos); byte[] bb = bos.toByteArray(); String str_sig = Base64.encodeToString(bb,Base64.DEFAULT); //create an instance of Database, open the database with it, createEntry and close it. NewDatabaseManager dataEntryTable2 = new NewDatabaseManager(this); dataEntryTable2.open(); dataEntryTable2.createEntryTable2(tick1_database_string, tick2_database_string, tick3_database_string, tick4_database_string, tick5_database_string, tick6_database_string, tick7_database_string, tick8_database_string, tick9_database_string, tick10_database_string, tick11_database_string, tick12_database_string, tick13_database_string, tick14_database_string, tick15_database_string, tick16_database_string, tick17_database_string, tick18_database_string, tick19_database_string, tick20_database_string, tick21_database_string, tick22_database_string ,str_appl_id, str_appt_id, str_recDate, str_tv_add_notes, str_sig); Intent i01 = new Intent(this, DatabaseLayout.class); startActivity(i01); } catch (Exception e) { //if the storing of database was unsuccessful display the dialog. didItWork = false; String error = e.toString(); Dialog dia = new Dialog(this); setTitle("Data store UnSuccessful"); TextView tv = new TextView(this); tv.setText("Please contact the developer" +e.toString()); dia.setContentView(tv); dia.show(); } finally { if(didItWork) { //if it worked then display this dialog Dialog d = new Dialog(this); setTitle("Data Stored"); TextView tv = new TextView(this); tv.setText("Success"); d.setContentView(tv); d.show(); } } } else { Dialog validationappTypeDialogdialog = new Dialog(this); validationappTypeDialogdialog.setTitle("Signature Required"); TextView tv1 = new TextView(this); tv1.setText("Please Sign first"); validationappTypeDialogdialog.setContentView(tv1); validationappTypeDialogdialog.show(); } ):

 case R.id.savesig:

         Bitmap returnedBitmap = Bitmap.createBitmap(mContent.getWidth(),
                 mContent.getHeight(), Bitmap.Config.ARGB_8888);
         Canvas canvas = new Canvas(returnedBitmap);
         Drawable bgDrawable = mContent.getBackground();
         if (bgDrawable != null)
             bgDrawable.draw(canvas);
         else
             canvas.drawColor(Color.WHITE);
         mContent.draw(canvas);


         ByteArrayOutputStream bs = new ByteArrayOutputStream();

         returnedBitmap.compress(Bitmap.CompressFormat.PNG, 50, bs);
         byteArray = bs.toByteArray();

         //send the captured signature to Check and Operations page
         Intent returncapSigIntent = new Intent();
         returncapSigIntent.putExtra("signature",byteArray);
        setResult(RESULT_OK, returncapSigIntent);
        finish();

完成活动B的代码:

{{1}}

0 个答案:

没有答案