0

New to android. I'm implementing a navigation drawer and upon selecting a specific button (position 0 in the drawer) I'm going to start an activity. These activities are defined in modules that I've imported.

To start with I created the navigation drawer. I'm using the position to determine which button was clicked. For testing I'm just using one button and one activity. I imported this project as a module: https://github.com/spacecowboy/NoNonsense-FilePicker

I want to be able to start his first activity from my menu. I removed the intent filter for his manifest so that my application would start first shown in the code below. The problem is that my application will still start the imported module first and not my navigation drawer. If I hit the back button then it goes to the navigation drawer. Can't post screenshots since I'm a noob.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fileexplorer"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".FileexplorerActivity"
            android:label="@string/title_activity_fileexplorer">
            <!--android:theme="@android:style/Theme.Holo"--> >
           <!-- <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity>

        <activity
            android:name=".FileChooser"
            android:label="Choose File" >
            //android:theme="@android:style/Theme.Holo">
                <action android:name="com.example.fileexplorer.FileChooser" />

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

    </application>

</manifest>

My MainActivity manifest file looks like this:

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:icon">
        <activity
            android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.Light"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

This is how I start the activity from the drawer code.

private void selectItem(int position) {

        Intent selectedIntent = null;
        switch(position){
            case 0:
            {
                selectedIntent = new Intent(this.getActivity(), FileexplorerActivity.class);
                startActivity(selectedIntent);
                break;
            }
            default:
                break;
        }
    } 
jonnyd42
  • 490
  • 1
  • 9
  • 23

2 Answers2

0

a dirty trick would be replace ".MainActivity" with ".FileChooser".. in your xml..

it should let you go with File Chooser if your MainActivity is running at launch now..

one other option would be cleaning and re-opening the project if you believe you are doing the things right..

Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0

So I figured out that it was working properly; I just had it so that the position 0 activity would start by default. Moved it to position 1 and the problem was solved.

jonnyd42
  • 490
  • 1
  • 9
  • 23