1

When I restart the app after I exit the app on Android by double clicking the back button, there is no splash screen and icon. I used this statement to exit the app:

ionic.Platform.exitApp(); 

I also tried using the following, but it doesn't solve my problem.

navigator.app.exitApp();

So, I don't know how to solve it, please help me.

JiaoXN
  • 65
  • 6

2 Answers2

2

According to documentations, the way ionic2 supports this is by adding the following options to config.xml:

<preference name="SplashShowOnlyFirstTime" value="true|false" />

However, as of version 4.0.1 there is a bug in the plugin. When the application is closed programatically, the next time we launch the application, without closing it from recent applications, the application crashes, and says app stopped unexpectedly. The following is the debug log of ADB for the same:

12-20 09:35:50.851 30375 30375 E AndroidRuntime: FATAL EXCEPTION: main
12-20 09:35:50.851 30375 30375 E AndroidRuntime: Process: com.mydomain.myapp, PID: 30375
12-20 09:35:50.851 30375 30375 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setAnimation(android.view.animation.Animation)' on a null object reference
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at org.apache.cordova.splashscreen.SplashScreen$4.run(SplashScreen.java:227)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at android.app.Activity.runOnUiThread(Activity.java:6050)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at org.apache.cordova.splashscreen.SplashScreen.removeSplashScreen(SplashScreen.java:217)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at org.apache.cordova.splashscreen.SplashScreen.access$1000(SplashScreen.java:49)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at org.apache.cordova.splashscreen.SplashScreen$5$1.run(SplashScreen.java:330)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:739)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:95)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:148)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7325)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
12-20 09:35:50.851 30375 30375 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I haved opened an issue for the same.

Musa Haidari
  • 2,109
  • 5
  • 30
  • 53
0

Add

<activity android:name="XXXX"
        android:excludeFromRecents="true" ...

in your AndroidManifest.xml's activity declaration.

Taken from @Mannaz's answer.

Regards.

Community
  • 1
  • 1
Hardik Vaghani
  • 2,163
  • 24
  • 46
  • Hi, Vaghani. Thanks your answer. It is a solution to my problem. But I think it's not the best solution, because It directly remove the app from application list , not like another android app. – JiaoXN Aug 18 '16 at 07:30
  • I am ionic 2 RC4. But this solution does not work for me. The application is not in the recent list, but also does not show the splash screen – Musa Haidari Dec 19 '16 at 10:52