how to Fix Unable to find explicit activity class

前端 未结 5 1347
心在旅途
心在旅途 2021-01-25 21:00
public class MultiColumnActivity extends Activity implements OnClickListener {
    private ArrayList> list;
    Button filterButton;
         


        
相关标签:
5条回答
  • 2021-01-25 21:28

    In your manifest file you have to register your DateActivity using <activity> tag not with <application> tag.

     <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.nous.demoexample.MultiColumnActivity
        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="com.nous.demoexample.Dateactvity
        android:label="@string/app_name"/>
    

    and start your Dateactivity as below:

     Intent intent = new Intent(MultiColumnActivity.this,Dateactvity.class);
        startActivity(intent);
    
    0 讨论(0)
  • 2021-01-25 21:29

    If your activity outside main package then declare like this :

    <application android:name="com.nous.demoexample.Dateactvity"></application> 
    

    Instead of

    Intent intent = new Intent();
    
    intent.setClassName("com.nous.demoexample", "com.nous.demoexample.Dateactvity");
    

    Write like this :

    Intent oIntent = new Intent(getApplicationContext(), com.nous.demoexample.Dateactvity.class);
    
    0 讨论(0)
  • 2021-01-25 21:34

    declare activity in manifest-

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.packageName.MultiColumnActivity
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    
    0 讨论(0)
  • 2021-01-25 21:41

    You should make an entry of activity like below

      <activity
            android:name=".Dateactvity" >
    
        </activity> 
    

    Not under application tag

      <application android:name=".Dateactvity"></application>
    

    http://developer.android.com/guide/topics/manifest/manifest-intro.html

    0 讨论(0)
  • 2021-01-25 21:42

    You need to declare like...

    <activity android:name="com.nous.demoexample.Dateactvity"></activity>
    

    And use intent like...

     Intent intent = new Intent(MultiColumnActivity.this,Dateactvity.class);
     startActivity(intent);
    
    0 讨论(0)
提交回复
热议问题