尝试通过侧面导航使用intent启动活动时应用程序崩溃

时间:2017-06-16 10:40:31

标签: android android-intent permissions manifest

每当我点击导航项目开始活动时,我的应用程序都会崩溃。我在最近6个小时内尝试过类似问题的所有解决方案,但无济于事。包括在manifest中注册活动,将intent (this,menu_profile.class);更改为(mainactivity.this, menu_profile.class); to`(getApplicationContext(),menu_profile.class);.谷歌许可(13)错误没有解决方案。

else if (itemId == R.id.third) {
                    Intent intent = new Intent(getApplicationContext(), Menu_Profile.class);
                    startActivity(intent);
                }

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.majesty.adesanmi.viewpager_nav">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        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=".Menu_Profile"
            android:label="DestinationActivity"/>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </application>

</manifest>

Logcat错误

06-16 09:46:56.913 2889-2889/? E/Trace: error opening trace file: Permission denied (13)
06-16 09:46:56.983 2889-2889/com.majesty.adesanmi.viewpager_nav E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
06-16 09:47:41.673 2889-2889/com.majesty.adesanmi.viewpager_nav E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  android.content.ActivityNotFoundException: Unable to find explicit activity class {com.majesty.adesanmi.viewpager_nav/com.majesty.adesanmi.viewpager_nav.Menu_About}; have you declared this activity in your AndroidManifest.xml?
                                                                                      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
                                                                                      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
                                                                                      at android.app.Activity.startActivityForResult(Activity.java:3351)
                                                                                      at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
                                                                                      at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                                                      at android.app.Activity.startActivityForResult(Activity.java:3312)
                                                                                      at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                                                      at android.app.Activity.startActivity(Activity.java:3522)
                                                                                      at android.app.Activity.startActivity(Activity.java:3490)
                                                                                      at com.majesty.adesanmi.viewpager_nav.MainActivity$2.onNavigationItemSelected(MainActivity.java:157)
                                                                                      at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:156)
                                                                                      at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
                                                                                      at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
                                                                                      at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
                                                                                      at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:342)
                                                                                      at android.view.View.performClick(View.java:4084)
                                                                                      at android.view.View$PerformClick.run(View.java:16966)
                                                                                      at android.os.Handler.handleCallback(Handler.java:615)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                                      at android.os.Looper.loop(Looper.java:137)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                                      at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                      at java.lang.reflect.Method.invoke(Method.java:511)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                                      at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

从您的Manifist文件中删除菜单profilr活动中的intent过滤器或替换此

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    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=".Menu_Profile"
        android:label="DestinationActivity"/>

</application>