Taskbar
Taskbar copied to clipboard
Intent: launch app
Hello tried out the freeform mode for the first time. Is there a possibility to launch apps through intent with specific size, position and show,hide ? Would be easy to implement, if not present yet, hope to see this in future. Thanks
The Intent
with ActivityOptions
can set starting location and size with parameter called LaunchBounds
. The Taskbar
uses it for freeform window bounds. But it doesn't provide mechanism to show/hide
window.
Ok. Found this on class U
launchApp(context, () -> {
Intent intent = new Intent(context, DummyActivity.class);
intent.putExtra("accessibility", true);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
try {
context.startActivity(intent, getActivityOptionsBundle(context, ApplicationType.APP_PORTRAIT, null));
} catch (IllegalArgumentException | SecurityException ignored) {}
});
But didnt find a receiver to start it from outside, i mean from other app. Did i understood it righ, this is not possible without a receiver? I will give a try to implement this. Hope you know which extras should be passed.
Ok. Found this on
class U
launchApp(context, () -> { Intent intent = new Intent(context, DummyActivity.class); intent.putExtra("accessibility", true); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); try { context.startActivity(intent, getActivityOptionsBundle(context, ApplicationType.APP_PORTRAIT, null)); } catch (IllegalArgumentException | SecurityException ignored) {} });
But didnt find a receiver to start it from outside, i mean from other app. Did i understood it righ, this is not possible without a receiver? I will give a try to implement this. Hope you know which extras should be passed.
It is not processed by other app, it is processed by frameworks, specifically TaskLaunchParameters
.
Before closing this thread. I would know your opinion about implementing such feature and hopefully you have some suggestions on doing this.
What would be great is to pass packagename, window size and position to open/close an app like on the normal way android doing it.
Before closing this thread. I would know your opinion about implementing such feature and hopefully you have some suggestions on doing this.
What would be great is to pass packagename, window size and position to open/close an app like on the normal way android doing it.
If you want to open one app with specific package name, and specific position, you can check the above launchApp
method you found in Taskbar
. If you want to close one app with specific package name, maybe you should check ActivityManager
methods, and make sure you have the granted permission to close one task or finish one process based on your found methods, if they exist.
If somebody interest in I implement a BroadcastReceiver and pass packagename and componentname from outside
public static class MyBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
String pkg= intent.getStringExtra("pkg");
String comp= intent.getStringExtra("comp");
final AppEntry entry = new AppEntry(pkg, comp, null, null, false);
long userId = entry.getUserId(context);
entry.setUserId(userId);
String windowSize = "standard";
// #todo: pass window dimension and position
U.launchApp(context, entry, windowSize, () -> {
Intent launch = new Intent(Intent.ACTION_VIEW);
try {
context.startActivity(intent, U.getActivityOptionsBundle(context, ApplicationType.APP_PORTRAIT, null));
} catch (ActivityNotFoundException | IllegalArgumentException ignored) {}
});
}
}
and register it in Manifest
<receiver android:name=".activity.MainActivity$MyBroadcastReceiver">
<intent-filter>
<action android:name="com.my.app" />
</intent-filter>
</receiver>
from outside send broadcast
Intent launchIntent = new Intent();
launchIntent.setAction("com.myapp");
launchIntent.putExtra("pkg", pkg);
launchIntent.putExtra("comp", comp);
launchIntent.setPackage("com.farmerbb.taskbar.debug");
launchIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(launchIntent);
This works fine, if checkbox for saving windowsize is enabled and one time setting the prefered windowsize and position. But only mobile Samsung S9. On Shield TV it is only working unless reboot.
U.launchApp(context, entry, windowSize, () ->
This windowSize is standard or the other definitions
Any tips to pass window dimensions and position ???