eclipse 如何解决“No Activity found to handle Intent”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10880026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:18:42  来源:igfitidea点击:

How to solve "No Activity found to handle Intent" error

androideclipse

提问by shubh

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.suven.Create_memo }

I just want to go from one activity to another but its giving me this error.

我只想从一项活动转到另一项活动,但它给了我这个错误。

my main activity code is as folllow

我的主要活动代码如下

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    btn1 = (Button)findViewById(R.id.button1);
    btn1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) 
        {
            try
            {
                Intent i=new Intent("com.android.suven.Create_memo");
            startActivity(i);
            }
            catch ( ActivityNotFoundException e) {
                e.printStackTrace();
            }

        }

    });  
    btn2 = (Button)findViewById(R.id.button2);
    btn2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) 
        {
            try
            {
                Intent i=new Intent("com.android.suven.Create_memo");
            startActivity(i);
            }
            catch ( ActivityNotFoundException e) {
                e.printStackTrace();
            }

    });          
  }
}

My logcat is like this:

我的 logcat 是这样的:

06-05 13:43:35.959: E/AndroidRuntime(275): FATAL EXCEPTION: main
06-05 13:43:35.959: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.suven/com.android.suven.Create_memo}: java.lang.NullPointerException
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread.access00(ActivityThread.java:125)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.os.Looper.loop(Looper.java:123)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-05 13:43:35.959: E/AndroidRuntime(275):  at java.lang.reflect.Method.invokeNative(Native Method)
06-05 13:43:35.959: E/AndroidRuntime(275):  at java.lang.reflect.Method.invoke(Method.java:521)
06-05 13:43:35.959: E/AndroidRuntime(275):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-05 13:43:35.959: E/AndroidRuntime(275):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-05 13:43:35.959: E/AndroidRuntime(275):  at dalvik.system.NativeStart.main(Native Method)
06-05 13:43:35.959: E/AndroidRuntime(275): Caused by: java.lang.NullPointerException
06-05 13:43:35.959: E/AndroidRuntime(275):  at com.android.suven.Create_memo.onCreate(Create_memo.java:56)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-05 13:43:35.959: E/AndroidRuntime(275):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-05 13:43:35.959: E/AndroidRuntime(275):  ... 11 more
06-05 13:43:39.199: I/Process(275): Sending signal. PID: 275 SIG: 9

回答by Chintan Raghwani

in your code-line

在您的代码行中

Intent i=new Intent("com.android.suven.Create_memo");

"com.android.suven.Create_memo"is taken as ACTION.

“com.android.suven.Create_memo”被当作​​动作。

Instead, you have to put

相反,你必须把

Intent i=new Intent(YourCurrentAivityName.this, Create_memo.class);

Also put

还放

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

in your AndroidManifest.xml file.

在您的 AndroidManifest.xml 文件中。

回答by Abhinai

This is NextActivity.java

这是 NextActivity.java

public class NextActivity extends Activity {

//Your member variable declaration here

// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
//Your code here
}
}

After creation of a new Activity, we have to register it in file ‘AndroidManifest.xml'. For registering we have to create an entry in ‘AndroidManifest.xml' as

创建新活动后,我们必须在文件“AndroidManifest.xml”中注册它。为了注册,我们必须在“AndroidManifest.xml”中创建一个条目作为

**<activity android:name=".NextActivity" android:label="@string/app_name"/>**

回答by Shrikant

Have you declared Create_memo activity in your manifest file? like:

您是否在清单文件中声明了 Create_memo 活动?喜欢:

<activity
            android:name="com.android.suven.Create_memo" />