Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

<activity
android:name=".TriggerActivity"
android:exported="true"
android:excludeFromRecents="true"
android:taskAffinity=""
android:theme="@android:style/Theme.NoDisplay" />

<service
android:name=".MainService"
android:enabled="true"
Expand Down
45 changes: 45 additions & 0 deletions app/src/main/java/com/crispim/recentapps/TriggerActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.crispim.recentapps

import android.app.Activity
import android.app.ActivityOptions
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.hardware.display.DisplayManager
import android.os.Bundle

class TriggerActivity : Activity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

openRecentApps()

finish()
}

private fun openRecentApps() {
try {
val intent = Intent().apply {
component = ComponentName(
"com.sec.android.app.launcher",
"com.android.quickstep.RecentsActivity"
)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
}

val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
val options = ActivityOptions.makeBasic()
val coverDisplay = displayManager.getDisplay(1)

if (coverDisplay != null) {
options.launchDisplayId = coverDisplay.displayId
startActivity(intent, options.toBundle())
} else {
startActivity(intent)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">RecentApps</string>
<string name="accessibility_service_description">RecentApps uses this service to detect user commands and quickly switch between recently opened applications.</string>
<string name="shortcut_recent_apps">Show recent apps</string>
</resources>
15 changes: 15 additions & 0 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="recent_apps"
android:enabled="true"
android:icon="@mipmap/recent_apps"
android:shortcutShortLabel="@string/shortcut_recent_apps"
android:shortcutLongLabel="@string/shortcut_recent_apps">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.crispim.recentapps"
android:targetClass="com.crispim.recentapps.TriggerActivity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>