我采取了将自己的活动放入启动过程的解决方法。
我的Service
启动了我的HelperActivity
附加功能,用于识别我希望启动/带到的任务。
HelperActivity
在onCreate()
中启动实际任务,使用overridePendingTransition()
动画更改。然后拨打finish()
以保持隐藏状态。
显然HelperActivity
需要从背后隐藏,所以清单反映了这一点。
也有安全问题,以这种幼稚的方法 - 看看相关的帖子由Commonsware:
这种类型的活动应尽可能安全。对于我的演示版本,我很乐意设置android:exported="false"
。
清单代码:
<activity
android:name=".SwitchAnimationHelperActivity"
android:excludeFromRecents="true"
android:exported="false"
android:noHistory="true" >
</activity>
HelperActivity代码:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String componentName = getIntent().getStringExtra("TASK_ID_API");
Intent newTask = new Intent(Intent.ACTION_MAIN);
newTask.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newTask.setComponent(ComponentName.unflattenFromString(componentName));
startActivity(newTask);
overridePendingTransition(R.anim.anim_zoom_in, R.anim.anim_slide_out_left);
// job is done
finish();
}
所以有它是 - 动画从Service
发射任务的一种方式。
解决方法是启动隐形活动,然后启动我想要显示的内容。但是这给这个过程增加了一点点延迟。 –