5

Android Lolipop has an api that allows for easy transitions between shared elements in different activities.

Activity transitions

It looks like this api doesn't support a transition with multiple views. Is there a way to do this using the same api?

EDIT

Following the advice from @pskink I use a different method

    ActivityOptions options = ActivityOptions
            .makeSceneTransitionAnimation(this, Pair.create((View)view, "viewPager"), Pair.create((View) fab, "fab"));
    startActivity(intent, options.toBundle());

This worked fine from ActivityA to ActivityB but hitting the back button results in this stacktrace

   A/OpenGLRenderer(17305): requireSurface() called but no surface set!
 A/libc(17305): Fatal signal 6 (SIGABRT), code -6 in tid 17349(RenderThread)
        Build fingerprint: 'google/hammerhead/hammerhead:5.0/LRX21O/1570415:user/release-keys'
        Revision: '11'
        ABI: 'arm'
        pid: 3364, tid: 3414, name: RenderThread  >>> com.example.package <<<
        signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
        Abort message: 'requireSurface() called but no surface set!'
            r0 00000000  r1 00000d56  r2 00000006  r3 00000000
            r4 9e9b5db8  r5 00000006  r6 0000003e  r7 0000010c
            r8 ac39bacc  r9 9e9b5d08  sl 9e9b5d00  fp ac39bb08
            ip 00000d56  sp 9e9b5858  lr b6f1faf9  pc b6f435d4  cpsr 600f0010
        backtrace:
            #00 pc 0003a5d4  /system/lib/libc.so (tgkill+12)
            #01 pc 00016af5  /system/lib/libc.so (pthread_kill+52)
            #02 pc 00017707  /system/lib/libc.so (raise+10)
            #03 pc 00013f75  /system/lib/libc.so (__libc_android_abort+36)
            #04 pc 00012a3c  /system/lib/libc.so (abort+4)
            #05 pc 00007a59  /system/lib/libcutils.so (__android_log_assert+88)
            #06 pc 0003b61f  /system/lib/libhwui.so
            #07 pc 0003b971  /system/lib/libhwui.so
            #08 pc 0003cf8d  /system/lib/libhwui.so
            #09 pc 0003cea5  /system/lib/libhwui.so
            #10 pc 0003d885  /system/lib/libhwui.so
            #11 pc 0003e27b  /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+66)
            #12 pc 000104d5  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+112)
            #13 pc 0005df4d  /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+72)
            #14 pc 00010045  /system/lib/libutils.so
            #15 pc 000162e3  /system/lib/libc.so (__pthread_start(void*)+30)
            #16 pc 000142d3  /system/lib/libc.so (__start_thread+6)

EDIT2

The only logs that I receive when I filter by package name are below. The first log looks like it is coming from render script, I posted the log above as I thought it is related.

A/OpenGLRenderer(11128): requireSurface() called but no surface set!

A/libc(11128): Fatal signal 6 (SIGABRT), code -6 in tid 11219 (RenderThread)

I/ci(11358): Making Creator dynamically

W/ResourcesManager(11358): Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no

W/ResourcesManager(11358): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no

EDIT3

So I was able to get this to work by disabling the mapfragment that was on activityA. I am still investigating why this would happen

jiduvah
  • 5,108
  • 6
  • 39
  • 55
  • Have you looked into the support library? I haven't looked to far into transitions but I would think something in the support library would have been built in for this. – zgc7009 Dec 03 '14 at 20:44
  • when starting a new Activity you have to create `ActivityOptions op = ActivityOptions.makeSceneTransitionAnimation(...)` and then call toBundle() method so it can be passed to `startActivity()` method – pskink Dec 03 '14 at 20:55
  • @pskink yes that is what I am doing at the moment. It is working well but I have 2 views I would like to do this with – jiduvah Dec 03 '14 at 21:03
  • use the version with params (Activity, Pair...) you can pass as many Pair's as you want, for example: ActivityOptions op = ActivityOptions.makeSceneTransitionAnimation(this, Pair.create((View) icon, "icon"), Pair.create((View) name, "name"), Pair.create((View) pkg, "pkg") – pskink Dec 03 '14 at 21:05
  • btw where do you call getWindow().setSharedElementExitTransition() and getWindow().setSharedElementEnterTransition() ? in the calling Activity or called one? – pskink Dec 03 '14 at 21:09
  • I missed that method. I don't call that, it's not necessary in api 21 – jiduvah Dec 03 '14 at 21:16
  • what don't you call? – pskink Dec 03 '14 at 21:17
  • getWindow().setSharedElementExitTransition() and getWindow().setSharedElementEnterTransition() – jiduvah Dec 03 '14 at 21:23
  • ah ok so you are using default Transitions – pskink Dec 03 '14 at 21:24
  • yes, it changes bounds as standard. I only want to move the position of 2 views – jiduvah Dec 03 '14 at 21:25
  • do you want to write is as an answer or should I delete the question? I think it could be useful to some people – jiduvah Dec 03 '14 at 21:38
  • Ok, so using two Pairs did the trick? – pskink Dec 03 '14 at 21:39
  • from ActivityA to ActivityB works prefectly but I get a runtime error when hitting the back button. With no stack trace?!? – jiduvah Dec 03 '14 at 21:50
  • runtime error with no stack trace? how come? – pskink Dec 03 '14 at 21:54
  • yeah i see and have no idea whats wrong... – pskink Dec 03 '14 at 22:01
  • The stack trace you've posted is not helpful for solving the problem. Please include the relevant part of the stack trace (i.e. the part of the trace where the Java exception was thrown). You will also need to include the code you have written as part of your question... simply stating "hitting the back button results in the following stacktrace" is not enough information to debug the problem. – Alex Lockwood Dec 03 '14 at 22:04
  • @alexLockwood . I have updated the logs with everything that was printed. I have posted the code above. I don't override any onfinish methods or anything similar within activityB so I don't think there is anything else relevant. Unless you have some suggestions? – jiduvah Dec 03 '14 at 22:20
  • The stack trace still isnt really helpful. Do any errors stand out when you dont filter by package name? – Alex Lockwood Dec 03 '14 at 22:30
  • There are only 2 other lines (I missed when I did copy and paste). I updated the first stacktrace. The only thing that stands out is.. requireSurface() called but no surface set! – jiduvah Dec 03 '14 at 22:38
  • @AlexLockwood It seems the mapfragment was interfering in some way. – jiduvah Dec 04 '14 at 00:04
  • 3
    I also have this problem and disabling MapFragment solves it, created bug report with this issue https://code.google.com/p/gmaps-api-issues/issues/detail?id=7712 – Vladimir Feb 26 '15 at 14:54
  • I had this exact same stack trace but don't use scene transition. It occurred when I hit the back button too. However, the root cause of my issue was that in the onStart of activity A, I was animating the view containing the map: `ViewCompat.animate(mapContainer)....start()`. Removing this fixed the issue. – Chris Feist Jul 09 '15 at 21:28

0 Answers0