问题标签 [taskaffinity]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
7251 浏览

android - Android 从广播接收器启动活动

我知道这可能不是最佳做法,但这是我想做的。

当我的广播接收器被调用时 - 启动一个不是全屏且具有透明背景的新活动 - 它在您当前的活动/桌面壁纸之上打开。

我到目前为止的代码如下:

我创建+调用一个新活动:

然后活动的主题是:

android:theme="@android:style/Theme.Translucent.NoTitleBar"

而且活动的代码只是一个简单布局的沼泽标准活动。但是,当该广播接收器启动活动时-它出现在应用程序启动时启动的上一个活动的顶部.....根据此图像显示: 替代文字

0 投票
2 回答
3539 浏览

android - 指定活动的Android taskAffinity问题

我在这里处理一个奇怪的问题。

基本上,我有一个应用程序(由另一位开发人员制作),它有一个活动,将其 taskAffinity 指定为“”,并将其 launchMode 指定为“singleTask”。

当手机收到通知时,我会在我的应用程序中启动一个带有 FLAG_ACTIVITY_NEW_TASK 标志的活动。

如果任务存在,我希望我的活动具有该其他应用程序的 taskAffinity。

当我这样做时,dumpsys activity我看到其他开发人员应用程序 TaskRecord 是:

但是,在我的活动清单中,我指定aj.streetphone.app它似乎没有将我的活动添加到该应用程序任务中。我尝试了另一个包名称,它似乎正在工作。问题可能与任务名称包含活动这一事实有关,而不仅仅是包名称(默认值)。

我基本上在使用“/”时遇到问题,因为清单不接受它。

我已经尝试转义由 unicode 添加的“/”,一切。请帮忙!

有任何想法吗?

0 投票
1 回答
572 浏览

virtual-machine - taskset inside qemu virtual machine not working as expected

I am emulating qemu for linux x86-64. In qemu virtual machine, I am using

to simultaneously issue 4 processes and bind them to four cores (prc is short for process). However, I find that once they start running; then afterwards, in-between, some cores (say 1 and 2) do not execute those processes but either idle or do something else. Can you suggest, what could be the reason for this or a way of improvement so that, I can make sure processes don't migrate from one core to another.

0 投票
2 回答
3584 浏览

android - 如何在完成后从最近的任务中删除带有 taskAffinity 的 singleTask 活动?

假设我们有两个活动。

A - 主要活动,即“启用主页启动器”(适当的意图过滤器等)

B - 具有 singleTask 规范(此活动只能有一个实例)和自定义 taskAffinity 的任务根活动(以区分是否与主要任务根)。

假设 B 代表一个任务,该任务仅在它未完成时才有效 - 完成它后返回它或从最近的任务重新开始它不是一个选项。

在某个时间点 - A 开始 B 开始一项新任务。目标是在用户完成 B 后从最近的任务列表中删除 B。用户可以从 B 导航到其他任务(使用主页长按),然后只要未完成就导航回 B。从启动器启动 A 不会将 B 带到前台,因为它们具有不同的任务相关性。

Android 将 B 识别为任务的根,因此 B 在最近任务列表中可见,即使它已完成,用户也可以随时返回。将 B 移动到与 A 的一个任务不是解决方案,因为在 B 运行期间 - 用户应该能够在 A 和 B 任务之间切换。将 excludeFromRecents 添加到 B 的清单中会将其从最近的任务列表中完全删除,这也是一个不好的解决方案。

如何实现?(对不起,我的英语不好)

0 投票
1 回答
1141 浏览

android - 从广播接收器启动一个活动会调出默认活动

我的应用程序包含两个活动,一个小部件和一个广播接收器。

第一个活动是默认活动,由家庭启动器调用。第二个活动是一个提醒对话框活动,它播放 MP3 并有一个关闭按钮。它将出现在主屏幕上。

我的小部件是一个自定义时钟,它设置一个闹钟,每分钟调用一个广播接收器,负责更新时钟。在特定时间有一些提醒,广播接收者调用提醒活动。

我的应用程序现在可以正常工作了,但是有一个小问题:当应用程序在后台打开时(它不在屏幕上),当广播接收器启动提醒活动时,默认活动首先出现并显示提醒活动。但是当我关闭应用程序时,主屏幕上会出现提醒活动并且没有问题。

这是我用来从接收器 startActivity 的代码:

这是android清单:

现在我在默认活动中使用这个解决方法来解决问题,它就像关闭应用程序一样工作:

我发现了更烦人的事情。如果主要活动未关闭,则广播接收器的每个调用都会再次打开活动,即使它已经打开。虽然如果主要活动关闭,后续调用将不会做任何事情。

0 投票
1 回答
4447 浏览

android - android:taskaffinity 是如何工作的?

android:taskaffinity属性如何工作?

据我了解,按 Home 键会将活动移回堆栈,但不会被销毁。我很困惑。

0 投票
1 回答
14346 浏览

linux - 在linux上从一开始就设置进程的cpu亲和力

我想在linux启动时设置进程的cpu亲和力。

有sched_setaffinity、taskset等方法,但需要进程的processid。它们可能会导致潜在的迁移,就像一个进程在一个核心上启动但在使用 sched_setaffinity/taskset 之后,它们被迁移到另一个核心。

我想做的是从一开始就在特定核心上启动一个新进程。

0 投票
3 回答
53729 浏览

android - Android 任务亲和说明

属性到底是做什么taskAffinity用的?我已经阅读了文档,但我不太了解。

任何人都可以用外行的术语解释任务亲和力吗?

0 投票
1 回答
477 浏览

android - FLAG_ACTIVITY_NEW_TASK 不能与 taskAffinity 一起工作

我的应用程序有 2 个启动活动 A 和 B。活动 B 有 taskAffinity="Task2"。

1) 从 android 菜单启动 B,更改那里的一些字段,然后按主页按钮。

2) 启动活动 A。从 A 启动带有标志FLAG_ACTIVITY_NEW_TASK的B。此字段未保存。那就是问题所在。

现在有这个:

  1. 主任务:任务2:B(第一)
  2. 主任务:A 任务2:B(第一)
  3. MainTask:A Task2:B(first) -> B(second)(OnTop)

但我想要这个:

  1. 主任务:任务2:B(第一)
  2. 主任务:A 任务2:B(第一)
  3. 主任务:A 任务2:B(第一)

请帮帮我。我想提前道歉,这是我的第一篇文章,我的英语不好。

我找到了答案。在清单文件中需要为活动 B 编写 android:launchMode="singleTop"。

0 投票
0 回答
543 浏览

linux - Process / thread scheduling on Linux: X server not running on other cpu cores?

Am unable to understand (what I think) is a peculiar situation wrt process/thread scheduling on Linux. [Env: Ubuntu 12.10 , kernel ver 3.5.0-... ]

A 'test' application (call it sched_pthread), will have a total of three threads - 'main' + two others; main() will spawn two new threads:

Thread 1 [main()]: Runs as SCHED_NORMAL (or SCHED_OTHER). It: Creates two threads (Thread 2 and Thread 3 below); they will automatically inherit the
scheduling policy and priority of main. Prints the character “m” to the terminal in a loop. Terminates.

Thread 2 [t2]: Sleeps for 2 seconds. Changes it's scheduling policy to SCHED_FIFO, setting it's real­time priority to the
value passed on the command line. Prints the character “2” to the terminal in a loop. Terminates.

Thread 3 [t3]: Changes it's scheduling policy to SCHED_FIFO, setting it's real­time priority to the value passed on the command line plus 10. Sleeps for 4 seconds. Prints the character “3” to the terminal in a loop. Terminates.

We run it as root. As per scheduling policy, we should first see main() print 'm' for about 2s, then it should get preempted by t2 (as it awakens after 2s) and we should see '2' appearing on the terminal for about 2s, after which t3 wakes up (it was asleep for 4s); it should now preempt everyone else & emit '3' to the display; after it dies, we should see '2's until p2 dies, then 'm's until main() dies.

So okay, this works: when i test it in console mode (no X server). Of course, i take care to run it as:

so that in effect it runs on only 1 processor core.

When I run the same thing in graphical mode (with X), after the initial 'm's by main(), there is a long-ish pause (a few seconds) during which nothing appears on the screen; then all of a sudden we get the 2's and 3's and m's slapped onto the screen! This can be explained : the X server (Xorg) was preempted by the SCHED_FIFO threads and hence could not 'paint' pixels on the screen.

However - here's the question at last - : how come the Xorg process was not scheduled / migrated onto some other core (so that it can continue updating the screen in parallel with the RT threads)?? taskset verifies that the cpu affinity mask of Xorg is 'f' (1111b) (i have 4 cores on my laptop).

Any ideas??

Here's the source code: https://dl.dropboxusercontent.com/u/9301413/code_shared/so_sched_pthrd.c -or- http://goo.gl/PLHBrC

TIA! -Kaiwan.