gpt4 book ai didi

java - "No Activity found"错误

转载 作者:行者123 更新时间:2023-11-30 03:43:02 25 4
gpt4 key购买 nike

这是我的主页代码:

package com.example.splasher;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
public static String text;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
EditText field= (EditText) findViewById (R.id.editText1);
field.setOnFocusChangeListener(new OnFocusChangeListener(){
public void onFocusChange(View v, boolean hasFocus){
if (hasFocus) ((EditText)v).selectAll();
}
});
text=field.getText().toString();
try{
startActivity(new Intent("com.example.splasher.View"));
}
catch(ActivityNotFoundException e){
}
}
});
}
}

这是我调用的 Activity 的代码:

package com.example.splasher;

import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class View extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.view);
// TextView textview=(TextView) findViewById (R.id.textView1);
// textview.setText(MainActivity.text);
}}

这是我的 list :

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

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

<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="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<activity
android:name=".View"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.splasher.View" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

我不明白为什么会出现此错误。有任何想法吗?名称都是相同的,并且具有相同的大小写字母。它们也都在 list 中进行了描述。

最佳答案

在您的 list 中,以大写形式键入 Activity 操作。

< Action android:name="COM.EXAMPLE.SPLASHER.VIEW"/>

除主要 Activity 外,所有 Activity 都这样做

关于java - "No Activity found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15451830/

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