threethan / LightningLauncher

App launcher for Oculus Quest and Android TV devices with a focus on speed and flexibility. Thanks for 80K sidequest downloads!
https://sidequestvr.com/app/21783
GNU General Public License v3.0
350 stars 24 forks source link

About using lua to start the program #152

Closed cgapk123 closed 4 months ago

cgapk123 commented 4 months ago

Hi, the previous launch method was to use "Activity.finish()" to close the activity, wait for about a second, and then start a new intent, but now I find that LightningLauncher will not be closed after launching the VR game. Why is this?

This is what I use now. It can start VR programs and 2D programs normally, but the startup will close the activity of the current program. Now I need to start the VR game without closing it.

function launchApp(pkgName, activityName) local intent = Intent() intent.setAction("android.intent.action.MAIN") intent.addCategory("android.intent.category.LAUNCHER") intent.setPackage(pkgName) intent.setClassName(pkgName, activityName) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

-- Destroy the current Activity activity.finish()

-- Wait for one second os.execute("sleep " .. tonumber(1))

-- Start a new application activity.startActivity(intent) end