sphinx02 / AppStarter

AppStarter | AppDrawer and Kodi / SPMC Updater for Amazon FireTV. Works without rooting your FireTV.
500 stars 1.16k forks source link

Feature Request - Kill Kodi - and Kill and Restart Kodi #38

Open sumpm1 opened 8 years ago

sumpm1 commented 8 years ago

I could not find where to put a feature request. If you can link me to where I can do so I will be happy to repost.

On my Fire Stick kodi will often freeze, in which case I have to open a "task killer app," find kodi, kill it, then restart kodi from within firestarter.

It would be awesome if firestarter allowed some options to automate such a process.

A shortcut in the main menu that would allow these options would be good.

It would also be nice if you could assign this action to a long press option on a remote key.

jeremy-r2 commented 8 years ago

I was going to request the same thing. It would be nice if there was an option to "Kill all open/running processes when at Firestarter homepage". This would be good for kodi since it hangs sometimes. Also, other amazon apps sometimes don't work right until you kill them and start them fresh.

jeremy-r2 commented 8 years ago

In AppStarter.java I see starting at line 78

if (isStartupAction || isClearPreviousInstancesForced) { // Start in new Task if startup -> perhaps prevents weird colors of kodi // that some users reported.. Log.d(AppStarter.class.getName(), "Using FLAG_ACTIVITY_CLEAR_TASK: isStartupAction=" + isStartupAction.toString() + ", isClearPreviousInstancesForced=" + isClearPreviousInstancesForced.toString()); launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); }

                // Launch the intent
                Log.d(AppStarter.class.getName(), "Starting launcher activity of package: " + packageName);
                context.startActivity(launchIntent);

The flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK are set, which is meant to kill previous instances? It doesn't seem to work on my fire tv stick (yes, I did have that setting turned on in Firestarter). If I exit Kodi by pressing Home on remote and go back to Firestarter, Kodi isn't started fresh if I launch it again. Also, other apps aren't started fresh either. This is a problem because, for a lot of apps, their assumption is that they are started fresh. If they are "paused" and then gone back to several hours later they don't work right.

Maybe add this code taken from (http://stackoverflow.com/questions/13847502/how-can-i-kill-processes-in-android): List packages; PackageManager pm; pm = getPackageManager(); //get a list of installed apps. packages = pm.getInstalledApplications(0);

ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

for (ApplicationInfo packageInfo : packages) { if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue; if(packageInfo.packageName.equals("mypackage")) continue; mActivityManager.killBackgroundProcesses(packageInfo.packageName); }

I have never programmed in java, so this probably has syntax errors. Maybe change it to:

if (isStartupAction || isClearPreviousInstancesForced) { // Start in new Task if startup -> perhaps prevents weird colors of kodi // that some users reported.. Log.d(AppStarter.class.getName(), "Using FLAG_ACTIVITY_CLEAR_TASK: isStartupAction=" + isStartupAction.toString() + ", isClearPreviousInstancesForced=" + isClearPreviousInstancesForced.toString()); launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); List packages; PackageManager pm; pm = getPackageManager(); //get a list of installed apps. packages = pm.getInstalledApplications(0); ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); for (ApplicationInfo packageInfo : packages) { if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1)continue; if(packageInfo.packageName.equals(packageName)){ mActivityManager.killBackgroundProcesses(packageInfo.packageName); } }

                }

                // Launch the intent
                Log.d(AppStarter.class.getName(), "Starting launcher activity of package: " + packageName);
                context.startActivity(launchIntent);