尝试打开视图数据库活动时“找不到处理Intent的活动”

时间:2013-05-29 02:56:20

标签: android sqlite

我正在尝试从教程中创建我的第一个SQLite数据库。当我尝试切换到保存数据库信息的活动时,它会崩溃。我正在使用onClickListener来启动意图。

我的意图代码是:

    Intent i = new Intent("com.example.database.SQLVIEW");
        startActivity(i);

我的清单:

   <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".SQLView"
        android:label="@string/title_activity_main" >
        <intent-filter> 
            <action android:name="com.example.database.SQLVIEW" />    
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

LogCat给了我:

05-28 22:25:50.205: D/AndroidRuntime(688): Shutting down VM
05-28 22:25:50.205: W/dalvikvm(688): threadid=1: thread exiting with uncaught exception                 (group=0x40a13300)
05-28 22:25:50.245: E/AndroidRuntime(688): FATAL EXCEPTION: main
05-28 22:25:50.245: E/AndroidRuntime(688): android.content.ActivityNotFoundException:           No Activity found to handle Intent { act=com.example.database.SQLVIEW }
05-28 22:25:50.245: E/AndroidRuntime(688):  at     android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
05-28 22:25:50.245: E/AndroidRuntime(688):  at     android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.app.Activity.startActivityForResult(Activity.java:3351)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.app.Activity.startActivityForResult(Activity.java:3312)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.app.Activity.startActivity(Activity.java:3522)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.app.Activity.startActivity(Activity.java:3490)
05-28 22:25:50.245: E/AndroidRuntime(688):  at com.example.database.MainActivity.onClick(MainActivity.java:71)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.view.View.performClick(View.java:4084)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.view.View$PerformClick.run(View.java:16966)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.os.Handler.handleCallback(Handler.java:615)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.os.Looper.loop(Looper.java:137)
05-28 22:25:50.245: E/AndroidRuntime(688):  at android.app.ActivityThread.main(ActivityThread.java:4745)
05-28 22:25:50.245: E/AndroidRuntime(688):  at     java.lang.reflect.Method.invokeNative(Native Method)
05-28 22:25:50.245: E/AndroidRuntime(688):  at java.lang.reflect.Method.invoke(Method.java:511)
05-28 22:25:50.245: E/AndroidRuntime(688):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-28 22:25:50.245: E/AndroidRuntime(688):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-28 22:25:50.245: E/AndroidRuntime(688):  at dalvik.system.NativeStart.main(Native Method)

由于

2 个答案:

答案 0 :(得分:1)

intent的代码错误。您尚未设置要调用另一个要调用的其他上下文表单。它应该是

Intent i = new Intent(YOURACTIVITY.this, SQLVIEW.class);
    startActivity(i);

在此处发布问题之前,请参阅Android Developer Documentation

答案 1 :(得分:0)

尝试在清单中的活动标记内提供完整的包名称。 可能是您的默认包名称不同

android:name="com.example.database.SQLView"