title: What is parameters in constructor (context, attrs)? How I can create new object this class? Java and Kotlin
body: <p>I try create sound spectrum, I created class view, which show spectrum, but to it work, i must create new object this class</p>
  <p>My View class:</p>
  <pre><code>class WaveformView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
      private var paint = Paint()
      private var amplitudes = ArrayList&lt;Float&gt;()
      private var spikes = ArrayList&lt;RectF&gt;()
      private var radius = 6f
      private var w = 9f
      init {
          paint.color = (Color.rgb(244, 81,30))
      }
      fun addAmplitude(amp: Float){
          amplitudes.add(amp)
  
          var left = 0f
          var top = 0f
          var right = left + w
          var bottom = amp
  
          spikes.add(RectF(left, top, right, bottom))
      }
  
      override fun draw(canvas: Canvas?) {
          super.draw(canvas)
          /*canvas?.drawRoundRect(RectF(20f, 30f, 20+30f, 30f + 60f), 6f, 6f, paint)
          canvas?.drawRoundRect(RectF(60f, 60f, 60+80f, 60f + 360f), 6f, 6f, paint)*/
          spikes.forEach{
              canvas?.drawRoundRect(it, radius, radius, paint)
          }
      }
  </code></pre>
  <p>My Main class:</p>
  <pre><code>//Volume
      MediaRecorder mediaRecorder;
      WaveformView waveform = new WaveformView(MainActivity.this, null); &lt;--- Error
  
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);..............
  </code></pre>
  <p>I wrote on Kotlin class view, but MainAct i wrote on Java (I don't now Kotlin, but i found decision)</p>
  <p>I need create a new object to use it</p>
  <pre><code>public void startRecording() {
          requestPerms();
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
              mediaRecorder = new MediaRecorder();
              mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
              mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
              mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  
              waveform.addAmplitude(mediaRecorder.getMaxAmplitude()); &lt;---here
          } else {
          Toast.makeText(this, &quot;Sorry, your MIC don't work&quot;, Toast.LENGTH_SHORT).show();
          }
      }
  </code></pre>
  <p>My Error:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.imagewithcamera, PID: 889
      java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.imagewithcamera/com.example.imagewithcamera.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3737)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4022)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:246)
          at android.app.ActivityThread.main(ActivityThread.java:8653)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
          at android.content.ContextWrapper.getResources(ContextWrapper.java:101)
          at android.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java:134)
          at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:128)
          at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:543)
          at android.view.View.&lt;init&gt;(View.java:5682)
          at android.view.View.&lt;init&gt;(View.java:5886)
          at android.view.View.&lt;init&gt;(View.java:5849)
          at android.view.View.&lt;init&gt;(View.java:5828)
          at com.example.imagewithcamera.WaveformView.&lt;init&gt;(WaveformView.kt:11)
          at com.example.imagewithcamera.MainActivity.&lt;init&gt;(MainActivity.java:62)
          at java.lang.Class.newInstance(Native Method)
          
  </code></pre>
  <p> </p>
  <p>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\</p>