title: Unable to instantiate activity ComponentInfo java.lang.ClassCastException
body: <p>I am trying to move to the activity below, but it is not working. on the emulator says that "the project keeps stopping".
  That is my first app that i am trying to build, so i would appreciate if you could explain in details.</p>
  
  <pre><code>package com.example.project3;
  
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
  import android.widget.Spinner;
  
  import androidx.annotation.Nullable;
  import androidx.fragment.app.Fragment;
  
  
     public class view extends Fragment {
          public static view newInstance() {
  
              Bundle args = new Bundle();
  
              view fragment = new view();
              fragment.setArguments(args);
              return fragment;
          }
  
          @Nullable
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
              View v=inflater.inflate(R.layout.activity_view,container,false);
              SQLiteDatabase db;
              db=getActivity().openOrCreateDatabase("employeeTasks.db", Context.MODE_PRIVATE,null);
              crearyllenar(db);
              listviewllenar(v, db);
  
              Button bfinish = (Button)v.findViewById(R.id.bfinish);
              bfinish.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      Spinner names = (Spinner)getView().findViewById(R.id.names);
                      Spinner dates = (Spinner)getView().findViewById(R.id.dates);
  
                      Spinner room = (Spinner)getView().findViewById(R.id.room);
                      Spinner cleanbed1 = (Spinner)getView().findViewById(R.id.cleanbed1);
                      Spinner brushfloor1 = (Spinner)getView().findViewById(R.id.brushfloor1);
                      Spinner mopfloor1 = (Spinner)getView().findViewById(R.id.mopfloor1);
                      Spinner cleanmirrow1 = (Spinner)getView().findViewById(R.id.cleanmirrow1);
                      Spinner cleanwindow1 = (Spinner)getView().findViewById(R.id.cleanwindow1);
                      Spinner removedust1 = (Spinner)getView().findViewById(R.id.removedust1);
                      Spinner emptybin1 = (Spinner)getView().findViewById(R.id.emptybin1);
  
  
                      EditText comments = (EditText)getView().findViewById(R.id.comments);
  
                      SQLiteDatabase db1;
  
                      db1=getActivity().openOrCreateDatabase("employeeTasks.db", Context.MODE_PRIVATE,null);
                      db1.execSQL("insert into employeeTask(names,dates,rooms,cleanbed,brushfloor,mopfloor,cleanmirrow,cleanwindow,removedust,emptybin,comments,commentsinfo) "+
                              "values('"+names.getSelectedItem().toString()+"','"+dates.getSelectedItem().toString()+"','"+room.getSelectedItem().toString()+"','"+cleanbed1.getSelectedItem().toString()+"','"+brushfloor1.getSelectedItem().toString()+"','"+mopfloor1.getSelectedItem().toString()+"','"+cleanmirrow1.getSelectedItem().toString()+"','"+cleanwindow1.getSelectedItem().toString()+"','"+removedust1.getSelectedItem().toString()+"','"+emptybin1.getSelectedItem().toString()+"','"+comments.getText().toString()+"','@@"+comments.getText().toString()+"')");
  
                      listviewllenar(getView(),db1);
                      names.setSelection(0);
                      dates.setSelection(0);
                      room.setSelection(0);
                      cleanbed1.setSelection(0);
                      brushfloor1.setSelection(0);
                      mopfloor1.setSelection(0);
                      cleanmirrow1.setSelection(0);
                      cleanwindow1.setSelection(0);
                      removedust1.setSelection(0);
                      emptybin1.setSelection(0);
                      comments.setText("");
  
  
                  }
              });
  
              return v;
          }
  
          private int listviewllenar(View v, SQLiteDatabase db) {
              Cursor c2=db.rawQuery("select * from employeeTask where estado=1 order by _id desc",null);
              String[] from=new String[]{"names","dates","rooms","cleanbed","brushfloor","mopfloor","cleanmirrow","cleanwindow","removedust","emptybin","comments","commentsinfo","time","id"};
              int[] to=new int[]{R.id.tnames, R.id.tdates, R.id.trooms, R.id.tcleanbed,  R.id.tbrushfloor, R.id.tmopfloor, R.id.tcleanmirrow,  R.id.tcleanwindow, R.id.tremovedust, R.id.temptybin,  R.id.tcomments, R.id.tcommentsinfo,R.id.ttime, R.id.tid};
  
              android.widget.ListView lv=(ListView) v.findViewById(R.id.listview);
              SimpleCursorAdapter adapter= new SimpleCursorAdapter(v.getContext(),R.layout.item,c2,from,to,0);
              lv.setAdapter(adapter);
              return 0;
          }
  
          private int crearyllenar(SQLiteDatabase db) {
              db.execSQL("create table if not exists employeeTask (_id integer primary key autoincrement unique,"+
                      "name text not null,dates text not null,room integer not null,cleanBed text not null,"+
                      "brushFloor text not null,mopFloor text not null,cleanMirrow text not null,cleanWindow text not null,"+
                      "removeDust text not null,emptyBin text not null,comments text not null,commentsInfo text not null,"+
                      "estado integer default 1,time datetime default (datetime(current_timestamp,'localtime'))) ");
              Cursor c1=db.rawQuery("select * from employeeTasks",null);
              if (c1.getCount()&lt;=0){
                db.execSQL("insert into employeeTask(name,dates,room,cleanBed,brushFloor,mopFloor,cleanMirrow,cleanWindow,removeDust,emptyBin,comments,commentsInfo) "+
                          "values('joe','tusday',1,'yes','yes','yes','yes','yes','yes','yes','yes','yes')");
  
              }
              return 0;
          }
      }
  </code></pre>
  
  <p>Please see below the Manifest too.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.project3"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".view"&gt;&lt;/activity&gt;
          &lt;activity android:name=".View_Lists" /&gt;
          &lt;activity android:name=".ListView" /&gt;
          &lt;activity android:name=".EmployeeTasks" /&gt;
          &lt;activity android:name=".DatabaseHelper" /&gt;
          &lt;activity android:name=".Selection" /&gt;
          &lt;activity android:name=".Login" /&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>And here is the error that i am getting:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.project3, PID: 19275
      java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.project3/com.example.project3.view}: java.lang.ClassCastException: com.example.project3.view cannot be cast to android.app.Activity
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3184)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
          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:2009)
          at android.os.Handler.dispatchMessage(Handler.java:107)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7319)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
       Caused by: java.lang.ClassCastException: com.example.project3.view cannot be cast to android.app.Activity
          at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
          at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
          at android.app.Instrumentation.newActivity(Instrumentation.java:1243)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3172)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396) 
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
          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:2009) 
          at android.os.Handler.dispatchMessage(Handler.java:107) 
          at android.os.Looper.loop(Looper.java:214) 
          at android.app.ActivityThread.main(ActivityThread.java:7319) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934) 
  I/Process: Sending signal. PID: 19275 SIG: 9
  Application terminated.
  </code></pre>