enter image description here How to call the Preference settings screen?

Call code:

public boolean onOptionsItemSelected(MenuItem item) {//Обработка нажатий сохранения, настройки и запуска файла. switch (item.getItemId()) { case R.id.action_settings: Intent settingsActivity = new Intent(getBaseContext(), Preferences.class); startActivity(settingsActivity); return true; 

SettingActivity Code:

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // загружаем предпочтения из ресурсов addPreferencesFromResource(R.xml.preferences); }[![введите сюда описание изображения][1]][1] 

ERROR CODE:

 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.blocnot, PID: 1835 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.blocnot/java.util.prefs.Preferences}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1761) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1485) at android.app.Activity.startActivityForResult(Activity.java:3736) at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) at android.app.Activity.startActivityForResult(Activity.java:3697) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856) at android.app.Activity.startActivity(Activity.java:4007) at android.app.Activity.startActivity(Activity.java:3975) at com.example.blocnot.MainActivity.onOptionsItemSelected(MainActivity.java:44) at android.app.Activity.onMenuItemSelected(Activity.java:2882) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:406) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:103) at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:667) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957) at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:127) at android.widget.AdapterView.performItemClick(AdapterView.java:300) at android.widget.AbsListView.performItemClick(AbsListView.java:1143) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3044) at android.widget.AbsListView.onTouchUp(AbsListView.java:3845) at android.widget.AbsListView.onTouchEvent(AbsListView.java:3617) at android.support.v7.widget.ListViewCompat.onTouchEvent(ListViewCompat.java:120) at android.view.View.dispatchTouchEvent(View.java:8388) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2424) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2158) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172) at android.widget.PopupWindow$PopupViewContainer.dispatchTouchEvent(PopupWindow.java:1682) at android.view.View.dispatchPointerEvent(View.java:8578) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4021) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3887) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5701) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5675) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5646) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:57 

Application terminated

  • 2
    String have you declared this activity in your AndroidManifest.xml? Are you talking about anything? Activation Preferences written in AndroidManifest.xml ? - post_zeew
  • How to announce? For the first time I work with it. - MPrect
  • 2
    Open the AndroidManifest.xml file, add the <activity android:name=".Preferences"> line inside the application . - post_zeew
  • one
    @MPrect, why do you run Preferences Activation, and display the settings in SettingActivity? - Yuriy SPb
  • Corrected. Just experimented from the fact that he could not find a solution. - MPrect

1 answer 1

Try adding your activity to AndroidManifest.xml .

To do this, open the AndroidManifest.xml file and add the following line inside the application tag:

 <activity android:name=".YourActivityName"> 

where YourActivityName is the name of your activity .

Also, you can create a new activity using the activity creation wizard:

File - New - Activity

In this case, information about the created activity will be added to AndroidManifest.xml automatically.