当从飞溅发送意图并完成飞溅活动方法时,onPause开始快速启动,但onDestroy调用太晚并且应用滞后于进入主活动或登录状态
和启动活动没有很长的时间,我会在动画结束时删除动画监听器
和应用程序logcat显示了这一点,您可以看到logacat的onPause调用首先和onDestroy调用的结束
E/splash: onPause:
W/ActivityThread: handleWindowVisibility: no activity for token
android.os.BinderProxy@9092794
D/EGL_emulation: eglMakeCurrent: 0xd0965960: ver 2 0 (tinfo 0xd1d09130)
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
V/FA: Activity resumed, time: 18138873
V/FA: onActivityCreated
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 4
W/min.attendence: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection)
W/min.attendence: Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection)
W/min.attendence: Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection)
V/FA: Recording user engagement, ms: 4713
V/FA: Activity paused, time: 18141536
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=4713, firebase_screen_class(_sc)=Splash, firebase_screen_id(_si)=-401415138442387316}]
I/min.attendence: Background concurrent copying GC freed 53772(3MB) AllocSpace objects, 9(640KB) LOS objects, 49% free, 3MB/7MB, paused 824us total 1.739s
I/min.attendence: Background concurrent copying GC freed 21035(1745KB) AllocSpace objects, 6(564KB) LOS objects, 49% free, 5MB/10MB, paused 1.079ms total 1.397s
I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
I/min.attendence: Background concurrent copying GC freed 65173(2MB) AllocSpace objects, 11(2MB) LOS objects, 49% free, 5MB/10MB, paused 806us total 3.993s
I/zzbz: Making Creator dynamically
W/min.attendence: Unsupported class loader
W/min.attendence: Skipping duplicate class check due to unsupported classloader
I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/min.attendence: Unsupported class loader
W/min.attendence: Skipping duplicate class check due to unsupported classloader
I/Google Maps Android API: Google Play services client version: 12451000
I/Google Maps Android API: Google Play services package version: 14799040
W/min.attendence: Verification of org.apache.http.HttpResponse ez.b(ei, java.util.Map) took 145.354ms
W/min.attendence: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
W/min.attendence: Unsupported class loader
W/min.attendence: Skipping duplicate class check due to unsupported classloader
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=Splash, firebase_previous_id(_pi)=-401415138442387316, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-401415138442387315}]
V/FA: Activity resumed, time: 18200633
I/Choreographer: Skipped 3778 frames! The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=66698ms; Flags=1, IntendedVsync=18141742732164, Vsync=18204709396312, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=18204721406120, AnimationStart=18204721509070, PerformTraversalsStart=18204722231380, D
D/EGL_emulation: eglMakeCurrent: 0xd0965960: ver 2 0 (tinfo 0xd1d09130)
V/StudioProfiler: Transformed class: com/google/android/gms/location/FusedLocationProviderClient
W/min.attendence: Changing class Lcom/google/android/gms/location/FusedLocationProviderClient;
W/min.attendence: Dex file created by class-definition time transformation of Lcom/google/android/gms/location/FusedLocationProviderClient; is not checked for all retransformation invariants.
W/min.attendence: Verification of com.google.android.gms.location.FusedLocationProviderClient com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(android.app.Activity) took 159.461ms
I/min.attendence: Background concurrent copying GC freed 47440(3MB) AllocSpace objects, 10(516KB) LOS objects, 49% free, 5MB/11MB, paused 860us total 3.326s
E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE)
I/chatty: uid=10088(ir.co.zit.amin.attendences) Binder:18467_5 identical 3 lines
E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE)
V/FA: Recording user engagement, ms: 12639
V/FA: Activity paused, time: 18213213
V/FA: Activity resumed, time: 18213277
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=12639, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-401415138442387315}]
I/Choreographer: Skipped 751 frames! The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xd0965960: ver 2 0 (tinfo 0xd1d09130)
D/EGL_emulation: eglCreateContext: 0x791389e0: maj 1 min 0 rcv 1
D/EGL_emulation: eglMakeCurrent: 0x791389e0: ver 1 0 (tinfo 0x7a6291e0)
I/OpenGLRenderer: Davey! duration=12878ms; Flags=1, IntendedVsync=18204775371399, Vsync=18217292037565, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=18217297977670, AnimationStart=18217298080630, PerformTraversalsStart=18217299002120, D
I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread.
E/splash: onDestroy:
V/FA: Inactivity, disconnecting from the service
飞溅活动代码:
public class Splash extends ActivityManagePermission {
String permissionAsk[] = {
//PermissionUtils.Manifest_GROUP_STORAGE,
PermissionUtils.Manifest_WRITE_EXTERNAL_STORAGE,
PermissionUtils.Manifest_READ_EXTERNAL_STORAGE,
//PermissionUtils.Manifest_GROUP_LOCATION,
PermissionUtils.Manifest_ACCESS_FINE_LOCATION,
PermissionUtils.Manifest_ACCESS_COARSE_LOCATION,
PermissionUtils.Manifest_READ_PHONE_STATE
};
@BindView(R.id.progressbar)
ProgressBar progressbar;
NfcAdapter mNfcAdapter;
private LocalStorage sessionManager;
private String id;
Context context;
private String TAG = "splash";
private boolean isLogin;
private UserPOJO user;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
sessionManager = new SessionManager(this);
context = this;
mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] tagId = tag.getId();
new Handler().post(() -> {
id = bytesToHex(tagId);
generatePermission();
});
} else startWithAnimation();
}
@Override
protected void onStart() {
super.onStart();
Log.e(TAG, "onStart: ");
}
@Override
protected void onResume() {
super.onResume();
Log.e(TAG, "onResume: ");
;
}
@Override
protected void onPause() {
super.onPause();
Log.e(TAG, "onPause: ");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.e(TAG, "onDestroy: ");
id = null;
mNfcAdapter = null;
}
public void startWithAnimation() {
int SPLASH_TIME_OUT = 2000;
ObjectAnimator animation = ObjectAnimator.ofInt(progressbar, "progress", 0, 10000);
animation.setDuration(SPLASH_TIME_OUT);
//animation.setInterpolator(new LinearInterpolator());
animation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
isLogin = sessionManager.isLoggedIn();
user = sessionManager.getUserDetails();
}
@Override
public void onAnimationEnd(Animator animator) {
Timber.e("animation finished");
generatePermission();
animation.removeListener(this);
}
@Override
public void onAnimationCancel(Animator animator) {
Timber.e("onAnimationCancel");
generatePermission();
animation.removeListener(this);
}
@Override
public void onAnimationRepeat(Animator animator) {
animation.removeListener(this);
}
});
animation.start();
}
final protected static char[] hexArray = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
int v;
for (int j = 0; j < bytes.length; j++) {
v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
public void generatePermission() {
askCompactPermissions(permissionAsk, new PermissionResult() {
@Override
public void permissionGranted() {
Timber.e("permissionGranted");
if (isLogin) {
TastyToast.makeText(getApplication(), user.getName() + "خوش آمدید", TastyToast.LENGTH_LONG, TastyToast.SUCCESS);
Intent intent = new Intent(Splash.this, MainActivity.class);
if (id != null) {
intent.putExtra("tag_id", id);
}
Splash.this.startActivity(intent);
Splash.this.finish();
return;
} else {
context.startActivity(new Intent(Splash.this, LoginActivity.class));
Splash.this.finish();
return;
}
}
@Override
public void permissionDenied() {
}
@Override
public void permissionForeverDenied() {
///Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null));
///intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
///startActivity(intent);
}
});
}
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}