No activity found to handle Intent/no launcher activity found manifest file issue

删除回忆录丶 提交于 2019-12-11 20:21:55

问题


Here's the problem guys, first i tried to run my application with Launch default activity as launch action (Run Configurations --> Android --> Launch action), the logcat kept telling me that it can't find the launcher activity and the application wouldn't even start, problem is i defined my launcher activity in the manifest file, but it's like it's not reading it at all.

So i tried to launch the splash activity by specifically telling it to run it through run configurations, it did launch but during the transition to the next activity it crashed again, the logcat says no activity found to handle intent, which again, I defined the way I did in other applications and worked alright there. Plase help it's a nightmare.

Here's the code for the MainActivity:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;


public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


Thread timer = new Thread()
{
    public void run(){
        try{
            sleep(6000);
        } catch (InterruptedException e){
             e.printStackTrace();
        } finally {
            Intent openStarting = new Intent("totaltrainer.com.WorkoutPlace");
            startActivity(openStarting);
        }
    }
};
timer.start();
}
@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
}
}

And Manifest:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:allowBackup="true"
    android:icon="@drawable/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="totaltrainer.com.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".WorkoutPlace"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="totaltrainer.com.WorkoutPlace" />
        </intent-filter>
    </activity>
    <activity
        android:name=".WorkoutHome"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="totaltrainer.com.WorkoutHome" />
        </intent-filter>
    </activity>
    <activity
        android:name=".WorkoutGym"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="totaltrainer.com.WorkoutGym" />
        </intent-filter>
    </activity>
</application>

</manifest>

回答1:


use "totaltrainer.com.WORKOUTGYM" and so on and below use this

<category android:name="android.intent.category.DEFAULT" />



回答2:


Problem 1

logcat kept telling me that it can't find the launcher activity and the application wouldn't even start

In your Manifest file, change below

<activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="totaltrainer.com.MAIN" />

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

as

<activity android:name="MainActivity">
    <!-- This activity is the main entry, should appear in app launcher -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

What happens when you define this Action and Category ?

The ACTION_MAIN action indicates this is the main entry point and does not expect any intent data.

The CATEGORY_LAUNCHER category indicates that this activity's icon should be placed in the system's app launcher. If the element does not specify an icon with icon, then the system uses the icon from the element.

These two must be paired together in order for the activity to appear in the app launcher.

Problem 2

the logcat says no activity found to handle intent

Your Manifest declaration seems fine.

In your activity class, change

Intent openStarting = new Intent("totaltrainer.com.WorkoutPlace");
            startActivity(openStarting);

as

Intent openStarting = new Intent();
openStarting.setAction("totaltrainer.com.WorkoutPlace");
startActivity(openStarting);


来源:https://stackoverflow.com/questions/28138916/no-activity-found-to-handle-intent-no-launcher-activity-found-manifest-file-issu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!