-3

Hi I have tried to add a class to my tabbed fragment and it is throwing an error, I thought at first that I was being stupid because I had not added the activity to the manifest but after I did it didn't work. How do you add an activity top the manifest and is the below error throwing this exception

ON: main

Process: com.androidbelieve.drawerwithswipetabs, PID: 14861 
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidbelieve.drawerwithswipetabs/com.androidbelieve.drawerwithswipetabs.BradClass}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1793)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1515)
at android.app.Activity.startActivityForResult(Activity.java:4026)
at android.app.Activity.startActivityForResult(Activity.java:3973)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:829)
at android.support.v4.app.Fragment.startActivity(Fragment.java:897)
at com.androidbelieve.drawerwithswipetabs.LeagueOne$1.onItemClick(LeagueOne.java:41)
at android.widget.AdapterView.performItemClick(AdapterView.java:339)
at android.widget.AbsListView.performItemClick(AbsListView.java:1544)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3721)
at android.widget.AbsListView$3.run(AbsListView.java:5660)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

This is how I wrote my activity

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">

        <activity
            android:name=".LeagueOne"
            android:label="leagues"></activity>
        <activity
            android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
            android:label="leagues"></activity>
                   <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74
JonniBravo
  • 1,051
  • 1
  • 11
  • 26

4 Answers4

2

Change your manifest to:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
       <activity
        android:name=".MainActivity"
        android:label="@string/app_name"/>

        <activity
            android:name=".LeagueOne"
            android:label="leagues"/>
        <activity
            android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
            android:label="leagues">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>
Alok Nair
  • 3,994
  • 3
  • 24
  • 30
1

Your manifest.xml has some wrong.

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
    </activity>

    <activity
        android:name=".LeagueOne"
        android:label="leagues"></activity>
    <activity
        android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
        android:label="leagues">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

If you want to use MainActivity as luncher,you can move intent-filter to MainActivity block.

Rico Teng
  • 236
  • 1
  • 7
1

Change your manifest to the given below, you put activity under activity thats the main problem all activity should be declared separate.

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        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=".LeagueOne"
            android:label="leagues"></activity>
        <activity
            android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
            android:label="leagues"></activity>
</application>
Madhur
  • 3,303
  • 20
  • 29
0

Add Activity in Manifest this way:

<activity
    android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
    android:label="leagues">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />    
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
activesince93
  • 1,716
  • 17
  • 37