-1

Whenever I run my app from Android studio, an Activity having

android:exported="true"

get's launched instead of launcher activity

<activity
        android:name=".activity.SplashScreen"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        android:windowSoftInputMode="stateHidden|adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

But once app installed, correct launcher activity opens, no issue. Only issue happens when I launch my app from Android studio(i.e. by running the app). So why this happens?

Without android:exported="true", on some devices, that activity not gets launched after clicking notification of my app. So is it good to keep exported true?

Also I can't post my entire manifest here

Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111
  • manifest.xml, launcher activity code please – Rahul Aug 31 '16 at 12:06
  • 5
    perhaps check your run configuration? Run -> Edit Configurations – Bill Aug 31 '16 at 12:06
  • "Without android:exported="true", on some devices, that activity not gets launched after clicking notification of my app" -- that is a separate problem. You should not need to export your activity to have it be opened via a `PendingIntent` used by a `Notification`. – CommonsWare Aug 31 '16 at 12:13
  • @CommonsWare not separate problem, but wanted to tell that's the reason why I have added android:exported="true" for that activity, and wanted to know is there any other alternative to android:exported="true" – Shirish Herwade Aug 31 '16 at 12:14
  • "wanted to know is there any other alternative to android:exported="true"" -- use `android:exported="false"`. If you are having problems with that on some devices, post a separate Stack Overflow question, with a [mcve] and an explanation of what problems you are having on what devices. – CommonsWare Aug 31 '16 at 12:17

2 Answers2

0

When running the app from Android Studio, you're probably using instant run. which applies the code changes to the current running process of your app, so instead of installing the app again, it applies the new changes to the running app, in that case you see the current running activity as it is.

http://android-developers.blogspot.com.eg/2016/04/android-studio-2-0.html https://developer.android.com/studio/run/index.html

Mina Wissa
  • 10,923
  • 13
  • 90
  • 158
-1

If it only happens in Android Studio and not when the app is installed, it is most likely a problem with the run configuration. You can access it by going to

Run -> Edit Configurations

Bill
  • 4,506
  • 2
  • 18
  • 29