Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Android studio/java help Mobile app/code keeps crashing.. There are no error messages present in both the MainActivity and the activity_main.xml MainActivity.java package com.example.admin.myapplication; import android.annotation.SuppressLint;

Android studio/java help

Mobile app/code keeps crashing..

There are no error messages present in both the MainActivity and the activity_main.xml

MainActivity.java

package com.example.admin.myapplication; import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.Color; import android.os.Bundle; import android.view.MotionEvent; import android.widget.ImageView; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private int blankPoint; private int standardPoint; private int unknownPoint; Bitmap bitmap; ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);  // ask user to select 3 points on color wheel selectPoints();  // obtain RGB values for each point int blankRGB = Color.valueOf(blankPoint).toArgb(); int standardRGB = Color.valueOf(standardPoint).toArgb(); int unknownRGB = Color.valueOf(unknownPoint).toArgb();  // convert RGB values to Hue values int blankHue = getHue(blankRGB); int standardHue = getHue(standardRGB); int unknownHue = getHue(unknownRGB);  // get user input for standard point concentration int standardConcentration = getStandardConcentration(); // obtain concentration of unknown point int unknownConcentration = getUnknownConcentration(blankHue, standardHue, standardConcentration, unknownHue);  // send output to user sendOutput(unknownConcentration); } @SuppressLint("ClickableViewAccessibility") private void selectPoints() { { imageView= findViewById(R.id.colorWheel); imageView.setDrawingCacheEnabled(true); imageView.buildDrawingCache(true); imageView.setOnTouchListener((v, event) -> { if (event.getAction()==MotionEvent.ACTION_DOWN) { bitmap = imageView.getDrawingCache(); event.getX(); event.getY(); int pixels = bitmap.getPixel((int) event.getX(), (int) event.getY()); if (blankPoint == 0) { blankPoint = pixels; } else if (standardPoint == 0) { standardPoint = pixels; } else if (unknownPoint == 0) { unknownPoint = pixels; } } return true; });}  // code to ask user to select 3 points on color wheel } private int getHue(int getHue){ return getHue; } private int getStandardConcentration() {  // code to get user input for standard point concentration return getStandardConcentration(); } private int getUnknownConcentration(int blankHue, int standardHue, int standardConcentration, int unknownHue) {  // code to obtain concentration of unknown point using the formula provided return (unknownHue-blankHue)/((standardHue-blankHue)/standardConcentration); } private void sendOutput(int unknownConcentration) { // code to send output to user System.out.println(unknownConcentration); } }

activity_main

?xml version="1.0" encoding="utf-8"?>        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

3. Describe the communicative power of group affiliations

Answered: 1 week ago