当前位置: 首页 > 知识库问答 >
问题:

找不到处理意图的活动

栾耀
2023-03-14

我对这个android编程是新手。所以,现在当我想从一个活动转到另一个活动时,我遇到了一个问题。当我在模拟器中运行时,它显示MyDemo在按下按钮指向另一个页面后已经停止工作。我已经阅读和尝试了很少的解决方案张贴在类似的问题,但似乎不能解决问题。任何建议都会对我有很大帮助。谢谢你。

这是错误日志

09-09 10:56:36.046 247 4-2489/com.example.dothis.demo d/openglenderer:>呈现脏区域请求:true 09-09 10:56:36.057 247 4-2474/com.example.dothis.demo d/:hostconnection::get()新主机连接建立0xAE0D8D40,tid 2474 09-09 10:56:36.070 247 4-2474/com.example.dothis.demo d/atlas:>验证映射...09-09 10:56:36.191 247 4-2489/com.example.dothis.demo D/:>HostConnection::GET()新主机连接建立0xAE0D8E50,tid 2489 09-09 10:56:36.205 247 4-2489/com.example.dothis.demo I/opengrenderer:>初始化EGL,版本1.4 09-09 10:56:36.220 247 4-2489/com.example.dothis.demo D/0>9-09 10:56:36.241 247 4-2489/com.example.dothis.demo W/EGL_emulation:EGLSURME FaceAttrib未实现09-09 10:56:36.241 247 4-2489/com.example.dothis.demo w/openglenderer:>未能在曲面0xA6C25680上设置EGL_SWAP_BEHAVIOR,error=EGL_Success 09-09 10:56:40.067 247 4-2474/com.example.dothis.demo d/AndroidRuntime:>关闭VM 09-09 10:56:40.067 247 4-2474/com.example.dothis.demo e/AndroidRuntime:>致命异常:main process:异常:在android的android.app.instrumentation.CheckStartActivityResult(instrumentation.java:1765)中找不到处理>intent{act=anotheractivity}的活动.app.instrumentation.execStartActivity(instrumentation.java:1485)在Android.app.activity.startActivityforResult(activity.java:3736)在Android.app.activity.startActivityforResult(activity.java:3697)在Android.app.activity.startActivity(activity.java:4007)在Android.app.activity.startActivity(activity.java:4007)在click.run(View.java:19749)在Android.os.handler.handleCallback(handler.java:739)在Android.os.handler.dispatchMessage(handler.java:95)在Android.os.handler.dispatchMessage(handler.java:135)在Android.app.activityThread.loop(looper.java:135)在Android.app.activityThread.main(activityThread.java:5221)在id.internal.os.zygoteinit.main(zygoteinit.java:694)09-09 10:56:42.512 247 4-2474/com.example.do这个.demo I/process:senging>signal。PID:2474签名:9

主要活动:

package com.example.dothis.demo;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    OnClickListener listnr=new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i= new Intent("AnotherActivity");
            startActivity(i);
        }
    };
    Button btn =(Button) findViewById(R.id.btn);
    btn.setOnClickListener(listnr);
}
}

另一项活动:

package com.example.dothis.demo;
import android.app.Activity;
import android.os.Bundle;
public class AnotherActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_another);
}
}

舱单:

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

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

<android:uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />
<android:uses-permission          android:name="android.permission.READ_PHONE_STATE" />
<android:uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />

<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=".AnotherActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="in.wptrafficanalyzer.AnotherActivity"   />

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

</application>

</manifest>

共有1个答案

姜增
2023-03-14

我相信你的行动需要一个完全合格的名字。

Intent intent = new Intent("com.example.dothis.demo.AnotherActivity");
startActivity(intent);

另一个选择是不使用一个操作来开始您的其他活动。

Intent intent = new Intent(MainActivity.this, AnotherActivity.class);
startActivity(intent);
 类似资料:
  • 我正在编写一个程序,当一个特定的短信到达手机时,我的应用程序中的主要活动应该被调用。我已经注册了一个< code>BroadcastReceiver,调用该活动的意图在< code>onReceive()方法中。问题是,每次我发送这个特定的短信,我得到一个关闭的力量。在读取logcat时,我看到了下面的NullPoint异常: 但就我而言,一切都做对了。谁能告诉我问题在哪里?提前谢谢你。 以下是清

  • 我有一个斜杠屏幕开始一个菜单,从我的菜单,我试图打开一个新的活动,尽管我得到了一个错误,当我这样做和应用程序崩溃。 我的清单 编辑:直接调用类工作:

  • 我有一个活动,我们称之为,它有一个。在适配器的代码中 当实际单击editOptionButton时,我得到以下堆栈跟踪 因此,我不知道为什么会出现这个错误,也不知道我能做什么。你们中有谁可能知道为什么或者以前经历过吗?

  • 在我的应用程序中,我有一个自定义的自动下载和安装APK,它是这样工作的 Android清单: 当使用普通文件时://它确实有效 在使用文件提供程序时,我是否遗漏了什么?活动没有启动是因为找不到文件吗?我需要额外的许可吗?(现在我有互联网,在外部存储上读写)

  • 我尝试检查上面的sdk版本marshmello,但每次我尝试运行它,总是导致这样的错误 不确定哪里出了问题,已经尝试了stackoverflow的一些建议,但仍然没有解决问题

  • 我正在尝试启用设备管理,这样我就可以在Android9中创建二级用户。 首先,使用ACTION_ADD_DEVICE_ADMIN发送一个意图,如下所示: deviceAdminReceiver必须在manifest.xml中预先定义,并使用适当的意图筛选器: 注意:我遵循了以下谷歌Android指南https://developer.Android.com/guide/topics/admin/d