关于片段交易

时间:2015-02-05 12:05:53

标签: android performance android-fragments

我在一个活动中有三个片段,并在活动中处理了背压。在中按在一个片段(CallingFragment)中,它加载DialerFragment,因为我已将其添加到backstack中加载CallingFragement并提供此日志。请告诉我为什么会这样?

加载CALLING FRAGMENT:

 void launchCallingFrag(String number, String name ,long time , boolean isongoing,String price )
    {
        String calleename= name;
        if(calleename==null)
        calleename=CommonUtility.getContactDisplayNameByNumber(number, context);

        callingScreenFragment.setNumber( number,calleename ,time,isongoing , price);
        ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.dial_fragment, callingScreenFragment, CALLING_FRAGMENT_TAG);

        dialerFragment = (DialerFragment)getSupportFragmentManager().findFragmentByTag(DIALER_FRAGMENT_TAG);

        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

            ft.addToBackStack(DIALER_FRAGMENT_TAG);


        ft.commit();
        overridePendingTransition(R.anim.animation1, R.anim.animation2);

    }

BACKPRESS:

  @Override
public void onBackPressed() {
Log.e("back press called ",""+getSupportFragmentManager().getBackStackEntryCount());
dialerFragment = (DialerFragment)getSupportFragmentManager().findFragmentByTag(DIALER_FRAGMENT_TAG);
if (dialerFragment!=null&&dialerFragment.isVisible()) {
// add your code here
Log.e("dialer fragment","dialer fragment ");
dialerFragment.onBackPress();
}
else {

callingScreenFragment = (CallingScreenFragment) getSupportFragmentManager().findFragmentByTag(CALLING_FRAGMENT_TAG);
if (callingScreenFragment!=null&&callingScreenFragment.isVisible()) {

Log.e("calling  fragment", "calling fragment ");

callingScreenFragment.onBackPress(fromNotification);

}
else {
recentDetailFragment = (RecentDetailFragment) getSupportFragmentManager().findFragmentByTag(LOG_DETAILS_FRAGMENT_TAG);
if (recentDetailFragment!=null&&recentDetailFragment.isVisible()) {
Log.e("recent   fragment","recent fragment ");
recentDetailFragment.onBackPress();
}
else {
super.onBackPressed();
}
}

}

日志:

 02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.addTargets
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.addTransitionTargets
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.beginDelayedTransition
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.captureExitingViews
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12194: Landroid/view/ViewGroup;.isTransitionGroup ()Z
    02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.cleanupTransitions
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.967  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.cloneTransition
    02-05 17:17:04.967  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.977  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.excludeTarget
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12022: Landroid/view/View;.getTransitionName ()Ljava/lang/String;
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12022: Landroid/view/View;.getTransitionName ()Ljava/lang/String;
    02-05 17:17:04.977  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.mergeTransitions
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.977  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.removeTargets
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.977  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method android.support.v4.app.FragmentTransitionCompat21.setEpicenter
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve check-cast 1450 (Landroid/transition/Transition;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/transition/Transition;)
            02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/FragmentTransitionCompat21$3; (1449)
            02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/FragmentTransitionCompat21$3;' failed
    02-05 17:17:04.977  10280-10280/com.myapp E/dalvikvm﹕ Could not find class 'android.support.v4.app.FragmentTransitionCompat21$3', referenced from method android.support.v4.app.FragmentTransitionCompat21.setSharedElementEpicenter
    02-05 17:17:04.977  10280-10280/com.myapp W/dalvikvm﹕ VFY: unable to resolve new-instance 422 (Landroid/support/v4/app/FragmentTransitionCompat21$3;) in Landroid/support/v4/app/FragmentTransitionCompat21;
    02-05 17:17:04.987  10280-10280/com.myapp W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/FragmentTransitionCompat21$1; (1449)
            02-05 17:17:04.987  10280-10280/com.myapp W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/FragmentTransitionCompat21$1;' failed
    02-05 17:17:04.987  10280-10280/com.myapp W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/FragmentTransitionCompat21$3; (1449)
            02-05 17:17:04.987  10280-10280/com.myapp W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/FragmentTransitionCompat21$3;' failed

1 个答案:

答案 0 :(得分:3)

不幸的是,这是由于android.support.v4库中的错误尚未解决(截至本答复发布之日)。

基本上,支持库使用API​​级别19和21 API,即使在没有足够高API级别的设备上运行也是如此。这是一个非常严重(甚至令人震惊)的错误,因为Android支持库的全部目的是将应用程序与API级别差异隔离开来!

在您的情况下,您显然是在API级别低于19的设备上运行,这是在引入整个android.transition包时。

相关的Android问题包括:7767089244。您可能希望访问这些问题并为其加注星标,和/或添加新问题。