-1

i created an activity that holds all my activities in a list and declared them in the android manifest. But i keep getting an error "class exception not found". don't know what to do. here is the code and the android manifest.

package com.activityexample.cookbook;

import android.app.ListActivity;
import android.app.SearchManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

public class ExtendsListActivity extends ListActivity implements OnItemClickListener{
    static final String[] Possible_Choices = new String[]{
        "Open Website Example",
        "Open Contacts",
        "Open Dialer",
        "Search Google Example",
        "Start Voice Command"
    };

final String searchTerms="supeman";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,Possible_Choices));
        getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        getListView().setTextFilterEnabled(true);
        getListView().setOnItemClickListener(this);
        //getListView().setOnItemClickListener(new OnItemClickListener() {
    //  });
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // TODO Auto-generated method stub
        switch (arg2){
        case 0:
            startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com/")));
            break;
        case 1:
            startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("content://contacts/people/")));
            break;

        case 2:
            startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("tel://08160212611/")));
            break;

        case 3:
            Intent i = new Intent(Intent.ACTION_WEB_SEARCH);
            i.putExtra(SearchManager.QUERY, searchTerms);
            startActivity(i);
            break;
        case 4:
            startActivity(new Intent(Intent.ACTION_VOICE_COMMAND));
            break;
            default: break;
        }

    }





}




    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.activityexample.cookbook"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
    <uses-permission android:maxSdkVersion="19" android:name="android.permission.READ_CONTACTS"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".TheMenu"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>

        </activity>
        <activity
            android:name=".ActivityEx"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.activityexample.cookbook.ActivityEx" />
                <category android:name="android.intent.category.DEFAULT"/>
                </intent-filter>
        </activity>

        <activity
            android:name=".ExtendsListActivity"
            android:label="@string/app_name" >
        </activity>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
        </activity>
    </application>

</manifest>
Aigbomian VII
  • 112
  • 1
  • 2
  • 7

2 Answers2

0

Without seeing the specific error, it looks like this is not the error that you expect. It looks like Android is trying to launch your "MAIN" activity TheMenu, but you have not created that activity. If you don't have it, don't declare it. And then you should probably modify the manifest so that ExtendsListActivity is the MAIN:

<activity
     android:name=".ExtendsListActivity"
     android:label="@string/app_name" >
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />  
     </intent-filter>
</activity>
Jim
  • 10,172
  • 1
  • 27
  • 36
0

If you do not declare activity in Manifest you will get the next error:

unable to find [Activity name]. Have you declared the Activity in your Android Manifest

java.lang.ClassNotFoundException will usually occur when you are missing jar file, or declared the wrong package name for your custom view in XML file, like this guy.

Community
  • 1
  • 1
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216