0

when I start from MainActiviy its going fine but when I add another activity and then click on the button and go to main activity its show me unfortunately stop working. I define the new activity as my launcher activity. when application starts its appear but when I click on button for my main activity its stop working here is my manifist

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

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.myapp.android.locationapi.maps.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<permission
    android:name="com.myapp.android.locationapi.maps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <uses-library android:name="com.google.android.maps"/>

    <activity
        android:name=".chek"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:name=".SignIn"/>
    <!--         <activity android:name=".MainActivity"></activity> -->
    <activity android:name=".Signup"/>
    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyDauI14NETaUpIitn9lfYvkar11cKKNhIc"/>

    <activity android:name=".MainActivity">
    </activity>
</application>

And here is my code for starting the activity:

startactivity(new Intent(chck.this,MainActivity.class));

here is my logcat

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nexurs/com.example.nexurs.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2455)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2517)
                                                                    at android.app.ActivityThread.access$800(ActivityThread.java:162)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                    at android.os.Looper.loop(Looper.java:189)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5529)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at java.lang.reflect.Method.invoke(Method.java:372)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
                                                                 Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
                                                                    at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:199)
                                                                    at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:133)
                                                                    at com.example.nexurs.MainActivity.onCreate(MainActivity.java:38)

1 Answers1

0

add these two lines inside the @style/AppTheme.NOactionBar

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
   </style>

otherwise remove android:theme="@style/AppTheme.NoActionBar"

vimal raj
  • 295
  • 1
  • 13
  • its still not working . . when i remove toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); from mainactivity its works but then its not showing my navigation drawer icon – naveed abbas Nov 14 '16 at 06:14