gpt4 book ai didi

android.content.ActivityNotFoundException : No Activity found to handle Intent splash screen

转载 作者:IT老高 更新时间:2023-10-28 22:22:23 31 4
gpt4 key购买 nike

我在启动画面后加载新 Intent 时遇到问题。我已经查看了与此异常相关的问题,但他们似乎都在处理诸如 google play 或 google maps 未正确引用之类的问题,这对我来说并非如此。

这些是我看过的相关问题

Not found activity to handle intent?

activity not found to handle intent

no activity found to handle intent

下面是我的 list 代码

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

<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Splash"
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=".HomePage"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.HOMEPAGE" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".OrderPlaced"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.ORDERPLACED" />

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

</manifest>

这是类启动的代码

package com.android.main;

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

public class Splash extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

Thread timer = new Thread(){
public void run(){
try{
sleep(1000);
}catch(InterruptedException e) {
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.android.main.HOMEPAGE");
startActivity(openStartingPoint);
}
}
};
timer.start();
}

@Override
protected void onPause() {

super.onPause();
finish();
}


}

这是我在启动画面后尝试加载的类 HomePage

package com.android.main;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class HomePage extends Activity {
/** Called when the activity is first created. */


TextView name;
EditText editName;
TextView drinks;
Spinner drinksSpinner;
TextView message;
CheckBox checkbox;
Button createOrderButton;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
createOrder();
}

public void createOrder(){

createOrderButton = (Button) findViewById(R.id.bCreateOrder);
createOrderButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
postInformationtoAPI();

}

private void postInformationtoAPI() {

goToOrderCompleted();
}

private void goToOrderCompleted() {
Intent intent = new Intent(HomePage.this , OrderPlaced.class);
HomePage.this.startActivity(intent);
Log.i("onClick", "trying to start new activity to change layout");
}
});

}
}

加载启动画面后应用强制退出并给出以下异常

03-14 22:32:33.553: E/AndroidRuntime(3166): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.main.HOMEPAGE }

对此的任何帮助将不胜感激

最佳答案

你必须区分 Intent 的构造函数,

 Intent openStartingPoint = new Intent("com.android.main.HOMEPAGE");

假设 com.android.main.HOMEPAGE作为Intent 的 Action 过滤器。这在您的应用程序的 android manifest.xml 文件中不可用。你有

<action android:name="android.intent.action.HOMEPAGE" />

应该是,

<action android:name="com.android.main.HOMEPAGE" />

只需更改它,

Intent openStartingPoint = new Intent(Splash.this, HOMEPAGE.class);

关于android.content.ActivityNotFoundException : No Activity found to handle Intent splash screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15614561/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com