Неточные описания ошибок / исключений при отладке шаблонов EJS

////////// firstActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.app.myapp.com.app44sendinginfofromoneactivitytoanother.MainActivity">

    <RelativeLayout
        android:layout_width="368dp"
        android:layout_height="495dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:orientation="vertical">

            <EditText
                android:id="@+id/edtName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Enter NAme"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edtLastName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Enter LastName"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edtEmail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Enter Email"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edtPassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Enter Password"
                android:inputType="textPassword" />

            <ImageView
                android:id="@+id/imgView"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                app:srcCompat="@android:drawable/ic_menu_report_image" />

            <RadioGroup
                android:id="@+id/rdoGroup"
                android:layout_width="match_parent"
                android:layout_height="50dp">

                <RadioButton
                    android:id="@+id/rdoMale"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Male" />

                <RadioButton
                    android:id="@+id/rdoFemale"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Female" />
            </RadioGroup>

            <Button
                android:id="@+id/btnSend"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Send" />
        </LinearLayout>
    </RelativeLayout>

</android.support.constraint.ConstraintLayout>

////////////// MainActivity.java

    public class MainActivity extends AppCompatActivity implements View.OnClickListener,CompoundButton.OnCheckedChangeListener{

    EditText edtName,edtLastName,edtEmail,edtPassword;
    ImageView imgView;
    RadioButton rdoMale,rdoFemale;
    Button btnSend;
    String genderType = "";
    int CAMERA_PIC_REQUEST = 99;
    Bitmap bitmap; // your bitmap

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edtName = (EditText) findViewById(R.id.edtName);
        edtLastName = (EditText) findViewById(R.id.edtLastName);
        edtEmail = (EditText) findViewById(R.id.edtEmail);
        edtPassword = (EditText) findViewById(R.id.edtPassword);
        btnSend = (Button) findViewById(R.id.btnSend);
        imgView = (ImageView) findViewById(R.id.imgView);
        rdoMale = (RadioButton) findViewById(R.id.rdoMale);
        rdoFemale = (RadioButton) findViewById(R.id.rdoFemale);
        btnSend.setOnClickListener(MainActivity.this);
        imgView.setOnClickListener(MainActivity.this);
        rdoMale.setOnCheckedChangeListener(MainActivity.this);
        rdoFemale.setOnCheckedChangeListener(MainActivity.this);

    }


    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()){
            case R.id.rdoMale:
                if (isChecked){
                    genderType = "Male";
                }else{

                    buttonView.setChecked(false);
                }

                break;
            case R.id.rdoFemale:
                if (isChecked){
                    genderType = "Female";
                }else{

                    buttonView.setChecked(false);
                }
                break;
        }
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.btnSend:

                    Intent intent = new Intent(MainActivity.this,SecondActivity.class);
                    intent.putExtra("NAME",edtName.getText().toString());
                    intent.putExtra("LASTNAME",edtLastName.getText().toString());
                    intent.putExtra("EMAIL",edtEmail.getText().toString());
                    intent.putExtra("PASSWORD",edtPassword.getText().toString());
                    intent.putExtra("GENDER",genderType);

                     //below is the code which you are looking for 

              -->    ByteArrayOutputStream bs = new ByteArrayOutputStream();
              -->    bitmap.compress(Bitmap.CompressFormat.PNG, 100, bs);
                     byte[] byteArray = bs.toByteArray();
                     intent.putExtra("PICTURE", byteArray);
                     startActivity(intent);
            break;
            case R.id.imgView:
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
                break;
        }
    }



    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode,resultCode,data);
        if (requestCode == CAMERA_PIC_REQUEST) {
            bitmap = (Bitmap) data.getExtras().get("data");
            imgView.setImageBitmap(bitmap);

        }
    }

}

//////////////////// SecondActivity.xml

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.app.myapp.com.app44sendinginfofromoneactivitytoanother.ResultActivity">

    <RelativeLayout
        android:layout_width="368dp"
        android:layout_height="495dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:orientation="vertical">

            <TextView
                android:id="@+id/txtName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="FirstName:"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/txtLast"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="LastName:"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/txtEmail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Email:"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/txtPassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Password:"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/txtGender"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="Gender:"
                android:textSize="24sp" />

            <ImageView
                android:id="@+id/imgViewResult"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                app:srcCompat="@android:drawable/ic_menu_report_image" />

        </LinearLayout>
    </RelativeLayout>
</android.support.constraint.ConstraintLayout>

///////// SecondActivity.Java

    public class SecondActivity extends AppCompatActivity {

    Context ctx ;
    TextView txtName,txtLast,txtEmail,txtPassword,txtGender;
    ImageView imgViewResult;
    Bitmap bitmap;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ctx = this;
        setContentView(R.layout.activity_result);

        txtName = (TextView) findViewById(R.id.txtName);
        txtLast = (TextView) findViewById(R.id.txtLast);
        txtEmail = (TextView) findViewById(R.id.txtEmail);
        txtPassword = (TextView) findViewById(R.id.txtPassword);
        txtGender = (TextView) findViewById(R.id.txtGender);
        imgViewResult = (ImageView) findViewById(R.id.imgViewResult);

        Bundle extras = getIntent().getExtras();
        String Name = extras.getString("NAME");
        String LastName = extras.getString("LASTNAME");
        String Email = extras.getString("EMAIL");
        String Password = extras.getString("PASSWORD");
        String Gender = extras.getString("GENDER");

        txtName.setText("Name: "+Name);
        txtLast.setText("LastName: "+LastName);
        txtEmail.setText("Email: "+Email);
        txtPassword.setText("Password: "+Password);
        txtGender.setText("Gender: "+Gender);

        byte[] byteArray = extras.getByteArray("PICTURE");
        bitmap = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
        imgViewResult.setImageBitmap(bitmap);


   }

}

HappyCoding:)

0
задан Marko36 26 February 2019 в 12:39
поделиться

1 ответ

Итак, я только что узнал, что EJS распечатывает код на терминал, если только отладчик не вмешивается для обработки исключения, прежде чем EJS сможет указать на ошибку. В моем сценарии я отлаживаю приложение, используя node --inspect app.js, с включенным автоматическим присоединением отладки в VS Code. Затем отладчик описывает исключение, как показано на скриншоте вопроса.

Как я узнал, что отладчик блокирует вывод EJS на терминал? У меня уже был браузер, запрашивающий приложение, когда я запустил его, и за секунду до того, как был присоединен отладчик, произошло исключение.

0
ответ дан Marko36 26 February 2019 в 12:39
поделиться
Другие вопросы по тегам:

Похожие вопросы: