Skip to content

Android: Activity with android:launchMode="singleTask" is blank after returning from background #14393

Description

@grebulon

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

Can't use a singleTask activity by adding android:launchMode="singleTask" to the activity's manifest definition in tiapp.xml.

Expected Behavior

singleTask activity is a must when using Chrome Tab for OAuth login. These tabs open on top of the opening activity and can only be removed by returning to the app with a Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP launch intent.

Actual behavior

With Titanium, when the app returns to foreground, it will be blank.
I suspect it's because of some fault in handling of onNewIntent in TiBaseActivity, TiRootActivity and other activity subsclasses. It may also be related to the implementation of TiRootActivity.onCreate which I don't understand at all...

Reproducible sample

  1. Download the test
  2. All I did was to explicitly add android:launchMode="singleTask" to the activity in the manifest (see: steps to reproduce)
  3. Build and run: ti build -p android
  4. Move the app to background and then click the launch icon to return to foreground
    -> The app will be blank.

Steps to reproduce

  1. Create a new test application for Android (ti create) - call it TestApp
  2. open tiapp.xml and inside <android><manifest> replace the default empty <application> tag with:
<application android:icon="@mipmap/ic_launcher">
	<activity android:launchMode="singleTask" android:label="@string/app_name" android:name=".TestappActivity">
		<intent-filter>
			<action android:name="android.intent.action.MAIN"/>
			<category android:name="android.intent.category.LAUNCHER"/>
		</intent-filter>
	</activity>
</application>
  1. This activity definition only actually adds android:launchMode="singleTask" to the default manifest that Titanium will create if we left the default <application/>
  2. Build: ti build -p android
  3. When the application starts, put it to background and then click the launch icon to return to foreground
  4. The app will be blank.

Platform

Android

SDK version you are using

13.0.1.GA

Alloy version you are using

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageThis issue hasn't been reviewed by maintainers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions