应用在启动时,创建activity报错闪退,报错信息是”Activity {packageName/compomentName} did not call through to super.onCreate()” ,经确认,这个问题是梆梆加固的问题,请遇到的开发者联系梆梆加固厂商,用最新的版本升级即可。
05-13 09:53:25.471 10732 15838 15838 E AndroidRuntime: FATAL EXCEPTION: main
05-13 09:53:25.471 10732 15838 15838 E AndroidRuntime: Process: xxxx, PID: xxx
05-13 09:53:25.471 10732 15838 15838 E AndroidRuntime: android.util.SuperNotCalledException: Activity {xxx/xxxx} did not call through to super.onCreate()
05-13 09:53:25.471 10732 15838 15838 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3549)
05-13 09:53:25.471 10732 15838 15838 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3729)
..............................................//此处省略
publicclassMyReceiverimplementsOnReceiveContentListener {
publicstaticfinal String[] MIME_TYPES = new String[] {"image/*", "video/*"};
@Override
public ContentInfoCompat onReceiveContent(View view, ContentInfoCompat contentInfo) {
Pair<ContentInfoCompat, ContentInfoCompat> split = contentInfo.partition(
item -> item.getUri() != null);
ContentInfo uriContent = split.first;
ContentInfo remaining = split.second;
if (uriContent != null) {
ClipData clip = uriContent.getClip();
for (int i = 0; i < clip.getItemCount(); i++) {
Uri uri = clip.getItemAt(i).getUri();
// App-specific logic to handle the URI ...
}
}
// Return anything that your app didn't handle. This preserves the default platform// behavior for text and anything else that you aren't implementing custom handling for.return remaining;
}
}
// Create a new event for the activity.
@Override
protectedvoidonCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout for the content view.
setContentView(R.layout.main_activity);
// Set up an OnPreDrawListener to the root view.final View content = findViewById(android.R.id.content);
content.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
publicbooleanonPreDraw() {
// Check if the initial data is ready.if (mViewModel.isReady()) {
// The content is ready; start drawing.
content.getViewTreeObserver().removeOnPreDrawListener(this);
returntrue;
} else {
// The content is not ready; suspend.returnfalse;
}
}
});
}
@Override
protectedvoidonCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...// Add a callback that's called when the splash screen is animating to// the app content.
getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
final ObjectAnimator slideUp = ObjectAnimator.ofFloat(
splashScreenView,
View.TRANSLATION_Y,
0f,
-splashScreenView.getHeight()
);
slideUp.setInterpolator(new AnticipateInterpolator());
slideUp.setDuration(200L);
// Call SplashScreenView.remove at the end of your custom animation.
slideUp.addListener(new AnimatorListenerAdapter() {
@Override
publicvoidonAnimationEnd(Animator animation) {
splashScreenView.remove();
}
});
// Run your animation.
slideUp.start();
});
}
// Get the duration of the animated vector drawable.long animationDuration = splashScreenView.getIconAnimationDurationMillis();
// Get the start time of the animation.long animationStart = splashScreenView.getIconAnimationStartMillis();
// Calculate the remaining duration of the animation.long remainingDuration = Math.max(
animationDuration - (SystemClock.uptimeMillis() - animationStart),
0L
);
// Listener is called immediately after the user exits PIP but before animating.
playerView.addOnLayoutChangeListener { _, left, top, right, bottom,
oldLeft, oldTop, oldRight, oldBottom ->
if (left != oldLeft || right != oldRight || top != oldTop
|| bottom != oldBottom) {
// The playerView's bounds changed, update the source hint rect to // reflect its new bounds.
val sourceRectHint = Rect()
playerView.getGlobalVisibleRect(sourceRectHint)
setPictureInPictureParams(
PictureInPictureParams.Builder()
.setSourceRectHint(sourceRectHint)
.build()
)
}
}
AndroidRuntime: FATAL EXCEPTION: main
AndroidRuntime: Process: com.xxx.app, PID: 25339
AndroidRuntime: java.lang.SecurityException: Not allowed to delete channel XXX with a foreground service
AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:2376)
AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2360)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2343)
AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2285)
AndroidRuntime: at android.app.INotificationManager$Stub$Proxy.deleteNotificationChannel(INotificationManager.java:4040)
AndroidRuntime: at android.app.NotificationManager.deleteNotificationChannel(NotificationManager.java:909)
AndroidRuntime: at androidx.core.app.NotificationManagerCompat.deleteNotificationChannel(SourceFile:2)
AndroidRuntime: at com.gyf.cactus.ext.c$a.run(SourceFile:1)
AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime: at android.os.Looper.loop(Looper.java:236)
AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8142)
AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
AndroidRuntime: at com.android.server.notification.NotificationManagerService$10.enforceDeletingChannelHasNoFgService(NotificationManagerService.java:3427)
AndroidRuntime: at com.android.server.notification.NotificationManagerService$10.deleteNotificationChannel(NotificationManagerService.java:3440)
AndroidRuntime: at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:1737)
AndroidRuntime: at android.os.Binder.execTransactInternal(Binder.java:1160)
AndroidRuntime: at android.os.Binder.execTransact(Binder.java:1129)
//获取预览窗口的宽高privatefinal TextureView.SurfaceTextureListener mSurfaceTextureListener
= new TextureView.SurfaceTextureListener() {
@Override
publicvoidonSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
openCamera(width, height);
}
@Override
publicvoidonSurfaceTextureSizeChanged(SurfaceTexture texture, int width, int height) {
configureTransform(width, height);
}
@Override
publicbooleanonSurfaceTextureDestroyed(SurfaceTexture texture) {
returntrue;
}
@Override
publicvoidonSurfaceTextureUpdated(SurfaceTexture texture) {
}
};
//得到最佳Camera图像输出尺寸privatestatic Size chooseOptimalSize(Size[] choices, int textureViewWidth,
int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) {
// Collect the supported resolutions that are at least as big as the preview Surface
List<Size> bigEnough = new ArrayList<>();
// Collect the supported resolutions that are smaller than the preview Surface
List<Size> notBigEnough = new ArrayList<>();
int w = aspectRatio.getWidth();
int h = aspectRatio.getHeight();
for (Size option : choices) {
if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight &&
option.getHeight() == option.getWidth() * h / w) {
if (option.getWidth() >= textureViewWidth &&
option.getHeight() >= textureViewHeight) {
bigEnough.add(option);
} else {
notBigEnough.add(option);
}
}
}
// Pick the smallest of those big enough. If there is no one big enough, pick the// largest of those not big enough.if (bigEnough.size() > 0) {
return Collections.min(bigEnough, new CompareSizesByArea());
} elseif (notBigEnough.size() > 0) {
return Collections.max(notBigEnough, new CompareSizesByArea());
} else {
Log.e(TAG, "Couldn't find any suitable preview size");
return choices[0];
}
}