I'm solving codepath prework question a Simple todo app. I created a listener such that when one single click on Adapter Holder it will open another edit activity where one can edit item, but the problem is it is showing ActivityNotFoundException error
this is the partial manifest file
<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/Theme.SimpleToDo"
tools:ignore="ExtraText">
<activity android:name=".EditActivity" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Single click listener
ItemsAdapter.OnClickListener onClickListener = new ItemsAdapter.OnClickListener() {
@Override
public void onItemClicked(int position) {
Log.d("MainActivity","Single Click poistion : " + position);
// Create new activity
Intent intent = new Intent(MainActivity.this, EditText.class);
// pass the data being edited
intent.putExtra(KEY_ITEM_TEXT, items.get(position));
intent.putExtra(KEY_ITEM_POSITION, position);
// display the activity
try {
/* your code */
startActivity(intent);
} catch ( ActivityNotFoundException e) {
e.printStackTrace();
}
}
};
Log file
W/System.err: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sam.simpletodo/android.widget.EditText}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1933)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
at android.app.Activity.startActivityForResult(Activity.java:4487)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at android.app.Activity.startActivityForResult(Activity.java:4445)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
at android.app.Activity.startActivity(Activity.java:4806)
at android.app.Activity.startActivity(Activity.java:4774)
at com.sam.simpletodo.MainActivity$2.onItemClicked(MainActivity.java:72)
at com.sam.simpletodo.ItemsAdapter$ViewHolder$1.onClick(ItemsAdapter.java:81)
at android.view.View.performClick(View.java:6294)
W/System.err: at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
One can find my complete repo here https://github.com/amanTHEBreaker/Google-Search-Fetcher-using-serpapi
You are trying to go to EditText
instead of EditActivity
Replace
Intent intent = new Intent(MainActivity.this, EditText.class);
with
Intent intent = new Intent(MainActivity.this, EditActivity.class);