那天有人问我,Android 的事件到底是怎么来的?

PCL 循环体素滤波 本文提出了一种自动循环体素滤波算法,用于解决点云配准中分辨率差异大、参数设置复杂的问题。算法通过计算点云分辨率(公式1),采用迭代方式调整体素尺寸(公式2),逐步逼近目标分辨率。该方法在保留几何特征的同时有效精简数据量,实现了均匀分辨率的自动调整。实验通过PCL库实现,展示了原始点云与滤波结果的对比效果,验证了算法在减少数据规模方面的有效性。该方法为点云配准提供了预处理解决方案,相关成果已发表于SCI期刊。 阅读详情

作者:酱爆大头菜

链接:

https://www.jianshu.com/p/470beda7ee64

本文主要针对的是 我们认为的事件分发 之前的流程,也就是说事件是怎么来的?一路又是怎么走下去的?

那为什么要研究事件的来龙去脉呢?其实我写本文之前是知道事件是以下的这种走向传递的。

Avtivity->PhoneWindow->DecorView->ViewGroup->View

直到有一天,有人问我那Activity是怎么接到事件的?我当时是一脸懵逼,然后就没有然后了,所以至于是谁问的我,估计你们也知道了。

本文争取以极简的方式来描述,如有问题欢迎指正。

我们开始表演

首先整个过程中会涉及以下几个类

  1. Activity
  2. PhoneWindow extends Window
  3. WindowManager extends ViewManager
  4. WindowManagerImpl implements WindowManager
  5. WindowManagerGlobal
  6. ViewRootImpl implements ViewParent
  7. WindowManagerService extends IWindowManager.Stub
  8. DecorView extends FrameLayout implements RootViewSurfaceTaker, WindowCallbacks
  9. InputChannel,InputQueue,WindowInputEventReceiver extends InputEventReceiver
  10. ViewRootHandler extends Handler

OK,我们先上结论,后展开说明,以下部分纯干货,如之前看过部分源码可直接看这部分,对源码不是很熟悉的也没有关系,下一个环节就是展开说明。

先上张图理解一下,图片内容较多,可点击原图欣赏无码大图 。

1. ActivityThread.performLaunchActivity() 中调用 Activity.attach(),创建PhoneWindow,PhoneWindow创建DecorView。

2. ActivityThread.handleResumeActivity()中调用Activity.makeVisible(),初始化WindowManager并调用WindowManager.addView()

3. 因为WindowManager是接口,找到其实现类并调用WindowManagerImpl.addView()。

4. 调用WindowManagerGlobal.addView(View view, ..., Window parentWindow, ...)

此时需要注意view为DecorView对象,该对象是通过ActivityThread.handleResumeActivity()中的PhoneWindow.getDecorView()获取,并直接赋值给Activity变量的。

5. WindowManagerGlobal.addView()创建了ViewRootImpl,并调用了ViewRootImpl.setView(view,...,...)

6. 连带创建InputChannel,InputQueue以及WindowInputEventReceiver对象并传入InputChannel和Looper

7. 其实Android事件的源头来自于用户输入行为,由硬件进行捕获,一般会保存在dev/input节点下,后续组装成KeyEvent/MotionEvent对象,经Native进入Java的InputEventReceiver.dispatchInputEvent()中。

8. ViewRootImpl.WindowInputEventReceiver extends InputEventReceiver,连带调用了enqueueInputEvent()->doProcessInputEvents-> deliverInputEvent(q),方法中获取到mFirstPostImeInputStage对象其实为ViewPostImeInputStage。

9. ViewPostImeInputStage extends InputStage 因此执行onProcess(),判断如果是触摸事件,调用processPointerEvent(),然后内部调用mView.dispatchPointerEvent(),此时的mView为DecorView,辗转调用到了DecorView.dispatchTouchEvent()

10. 通过 mWindow.getCallback()获取Window.Callback然后调用Window.Callback.dispatchTouchEvent(),这个Callback就是PhoneWindow里的mCallback,而mCallback则是Activity的attach()赋值的,此处也就自然调用到了Activity中,后续就是我们都知道的事件分发了,一个完整的闭环就结束了。

ActivityThread.performLaunchActivity()

 

  private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) {
          ...
            if (activity != null) {
               ...
              //可以看到此处调用了Activity的attach()方法
                activity.attach(appContext, this, getInstrumentation(), r.token,
                        r.ident, app, r.intent, r.activityInfo, title, r.parent,
                        r.embeddedID, r.lastNonConfigurationInstances, config,
                        r.referrer, r.voiceInteractor, window, r.configCallback,
                        r.assistToken);
            ...
            }
}

1.1 Activity.attach()中进行了PhoneWindow初始化,并设置CallBack对象。

 

final void attach(Context context, ActivityThread aThread,
            Instrumentation instr, IBinder token, int ident,
            Application application, Intent intent, ActivityInfo info,
            CharSequence title, Activity parent, String id,
            NonConfigurationInstances lastNonConfigurationInstances,
            Configuration config, String referrer, IVoiceInteractor voiceInteractor,
            Window window, ActivityConfigCallback activityConfigCallback, IBinder assistToken) {
        attachBaseContext(context);

        mFragments.attachHost(null /*parent*/);
        //PhoneWindow初始化
        mWindow = new PhoneWindow(this, window, activityConfigCallback);
        mWindow.setWindowControllerCallback(mWindowControllerCallback);
        mWindow.setCallback(this);
        mWindow.setOnWindowDismissedCallback(this);
        mWindow.getLayoutInflater().setPrivateFactory(this);

2.ActivityThread.handleResumeActivity() 通过PhoneWindow获取DecorView,然后调用activity.makeVisible()

 

 public void handleResumeActivity(IBinder token, boolean finalStateRequest, boolean isForward,
            String reason) {
       ...
        if (r.window == null && !a.mFinished && willBeVisible) {
            r.window = r.activity.getWindow();
            View decor = r.window.getDecorView();
            decor.setVisibility(View.INVISIBLE);
            ViewManager wm = a.getWindowManager();
            WindowManager.LayoutParams l = r.window.getAttributes();
            a.mDecor = decor;
            l.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
            ...
            if (a.mVisibleFromClient) {
                if (!a.mWindowAdded) {
                    a.mWindowAdded = true;
                    wm.addView(decor, l);
                } else {
                    a.onWindowAttributesChanged(l);
                }
            }

          } else if (!willBeVisible) {
            if (localLOGV) Slog.v(TAG, "Launch " + r + " mStartedActivity set");
            r.hideForNow = true;
        }
       ...
            if (r.activity.mVisibleFromClient) {
                r.activity.makeVisible();
            }
        }
 ...
    }

2.1 PhoneWindow创建DecorView的过程

 

   @Override
    public final @NonNull View getDecorView() {
        if (mDecor == null || mForceDecorInstall) {
            //组装DecorView
            installDecor();
        }
        return mDecor;
    }

   private void installDecor() {
        mForceDecorInstall = false;
        if (mDecor == null) {
            //获取DecorView
            mDecor = generateDecor(-1);
            mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
            mDecor.setIsRootNamespace(true);
            if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
                mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
            }
        }
    }
      //返回值就是DecorView
    protected DecorView generateDecor(int featureId) {
        // System process doesn't have application context and in that case we need to directly use
        // the context we have. Otherwise we want the application context, so we don't cling to the
        // activity.
        Context context;
        if (mUseDecorContext) {
            Context applicationContext = getContext().getApplicationContext();
            if (applicationContext == null) {
                context = getContext();
            } else {
                context = new DecorContext(applicationContext, this);
                if (mTheme != -1) {
                    context.setTheme(mTheme);
                }
            }
        } else {
            context = getContext();
        }
        return new DecorView(context, featureId, this, getAttributes());
    }

2.2. activity.makeVisible()过程

  void makeVisible() {
        if (!mWindowAdded) {
            ViewManager wm = getWindowManager();
            //此时调用的其实事WindowManager.addView()
            wm.addView(mDecor, getWindow().getAttributes());
            mWindowAdded = true;
        }
        mDecor.setVisibility(View.VISIBLE);
    }

3. WindowManager是接口,找到其实现类并调用WindowManagerImpl.addView()

 

@Override
public void addView(@NonNull View view, @NonNull ViewGroup.LayoutParams params) {
    applyDefaultToken(params);
   //此时调用的是WindowManagerGlobal.addView()
    mGlobal.addView(view, params, mContext.getDisplayNoVerify(), mParentWindow,
            mContext.getUserId());
}

4. WindowManagerGlobal.addView() 初始化ViewRootImpl,然后调用root.setView()

public void addView(View view, ViewGroup.LayoutParams params,
            Display display, Window parentWindow, int userId) {
      ...
         synchronized (mLock) {
           ...
           //初始化ViewRootImpl
           root = new ViewRootImpl(view.getContext(), display);
           view.setLayoutParams(wparams);

            mViews.add(view);
            mRoots.add(root);
            mParams.add(wparams);

            // do this last because it fires off messages to start doing things
            try {
                root.setView(view, wparams, panelParentView, userId);
            } catch (RuntimeException e) {
                // BadTokenException or InvalidDisplayException, clean up.
                if (index >= 0) {
                    removeViewLocked(index, true);
                }
                throw e;
            }
        }
    }

5. ViewRootImpl.setView(view,...,...) 创建InputChannel, InputQueue, WindowInputEventReceiver

 

public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView, int userId) {
    synchronized (this) {
        if (mView == null) {
            mView = view;
       ...
            // Schedule the first layout -before- adding to the window
            // manager, to make sure we do the relayout before receiving
            // any other events from the system.
            requestLayout();
            InputChannel inputChannel = null;
            if ((mWindowAttributes.inputFeatures
                    & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) {
                inputChannel = new InputChannel();
            }
           if (inputChannel != null) {
                if (mInputQueueCallback != null) {
                    //创建对象
                    mInputQueue = new InputQueue();
                    mInputQueueCallback.onInputQueueCreated(mInputQueue);
                }
                mInputEventReceiver = new WindowInputEventReceiver(inputChannel,
                        Looper.myLooper());
          }

    }
}

6. 其实Android事件的源头来自于用户输入行为,由硬件进行捕获,一般会保存在 dev/input 节点下,后续组装成KeyEvent/MotionEvent对象,经Native进入Java的InputEventReceiver.dispatchInputEvent()中。

我们先分析InputEventReceiver

 

private void dispatchInputEvent(int seq, InputEvent event) {
        mSeqMap.put(event.getSequenceNumber(), seq);
        onInputEvent(event);
    }

public void onInputEvent(InputEvent event) {
        finishInputEvent(event, false);
    }

由于InputEventReceiver是abstract类,因此需要找到对应的实现类,此时第5步中 WindowInputEventReceiver 即是实现类,因此找到重写的onInputEvent()方法进行下一步分析。

7. ViewRootImpl.WindowInputEventReceiver extends InputEventReceiver,连带调用了enqueueInputEvent()->doProcessInputEvents-> deliverInputEvent(q),方法中获取到mFirstPostImeInputStage对象其实为ViewPostImeInputStage。

@Override
public void onInputEvent(InputEvent event) {
    Trace.traceBegin(Trace.TRACE_TAG_VIEW, "processInputEventForCompatibility");
    List<InputEvent> processedEvents;
    try {
        processedEvents =
            mInputCompatProcessor.processInputEventForCompatibility(event);
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_VIEW);
    }
    if (processedEvents != null) {
        if (processedEvents.isEmpty()) {
            // InputEvent consumed by mInputCompatProcessor
            finishInputEvent(event, true);
        } else {
            for (int i = 0; i < processedEvents.size(); i++) {
                enqueueInputEvent(
                        processedEvents.get(i), this,
                        QueuedInputEvent.FLAG_MODIFIED_FOR_COMPATIBILITY, true);
            }
        }
    } else {
        enqueueInputEvent(event, this, 0, true);
    }
}

void enqueueInputEvent(InputEvent event, InputEventReceiver receiver, int flags, boolean processImmediately) {
QueuedInputEvent q = obtainQueuedInputEvent(event, receiver, flags);

// Always enqueue the input event in order, regardless of its time stamp.
// We do this because the application or the IME may inject key events
// in response to touch events and we want to ensure that the injected keys
// are processed in the order they were received and we cannot trust that
// the time stamp of injected events are monotonic.
QueuedInputEvent last = mPendingInputEventTail;
if (last == null) {
    mPendingInputEventHead = q;
    mPendingInputEventTail = q;
} else {
    last.mNext = q;
    mPendingInputEventTail = q;
}
mPendingInputEventCount += 1;
Trace.traceCounter(Trace.TRACE_TAG_INPUT, mPendingInputEventQueueLengthCounterName,
        mPendingInputEventCount);

if (processImmediately) {
    doProcessInputEvents();
} else {
    scheduleProcessInputEvents();
}
}

void doProcessInputEvents() {
// Deliver all pending input events in the queue.
while (mPendingInputEventHead != null) {
    QueuedInputEvent q = mPendingInputEventHead;
    mPendingInputEventHead = q.mNext;
    if (mPendingInputEventHead == null) {
        mPendingInputEventTail = null;
    }
    q.mNext = null;

    mPendingInputEventCount -= 1;
    Trace.traceCounter(Trace.TRACE_TAG_INPUT, mPendingInputEventQueueLengthCounterName,
            mPendingInputEventCount);

    long eventTime = q.mEvent.getEventTimeNano();
    long oldestEventTime = eventTime;
    if (q.mEvent instanceof MotionEvent) {
        MotionEvent me = (MotionEvent)q.mEvent;
        if (me.getHistorySize() > 0) {
            oldestEventTime = me.getHistoricalEventTimeNano(0);
        }
    }
    mChoreographer.mFrameInfo.updateInputEventTime(eventTime, oldestEventTime);

    deliverInputEvent(q);
}

// We are done processing all input events that we can process right now
// so we can clear the pending flag immediately.
if (mProcessInputEventsScheduled) {
    mProcessInputEventsScheduled = false;
    mHandler.removeMessages(MSG_PROCESS_INPUT_EVENTS);
}
}

private void deliverInputEvent(QueuedInputEvent q) {
 ...
 try {
    ...
    InputStage stage;
    if (q.shouldSendToSynthesizer()) {
        stage = mSyntheticInputStage;
    } else {
        //此时返回两个InputStage类型的对象,这个InputStage为abstract因此需要找对应的实现类。
        stage = q.shouldSkipIme() ? mFirstPostImeInputStage : mFirstInputStage;
    }

    if (q.mEvent instanceof KeyEvent) {
        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "preDispatchToUnhandledKeyManager");
        try {
            mUnhandledKeyManager.preDispatch((KeyEvent) q.mEvent);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
        }
    }

    if (stage != null) {
        handleWindowFocusChanged();
        stage.deliver(q);
    } else {
        finishInputEvent(q);
    }
} finally {
    Trace.traceEnd(Trace.TRACE_TAG_VIEW);
}
}

此时需要注意这个InputStage 的实现类相对比较多,不过可以重点看下setView()方法的末尾,着重看mFirstPostImeInputStage赋值逻辑。

 

public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView, int userId) {
  ....               
  // Set up the input pipeline.
    CharSequence counterSuffix = attrs.getTitle();
    mSyntheticInputStage = new SyntheticInputStage();
    //最终new了ViewPostImeInputStage
    InputStage viewPostImeStage = new ViewPostImeInputStage(mSyntheticInputStage);
    //继续看viewPostImeStage赋值
    InputStage nativePostImeStage = new NativePostImeInputStage(viewPostImeStage,
            "aq:native-post-ime:" + counterSuffix);
    //初始化并传入nativePostImeStage,需要查看nativePostImeStage赋值逻辑,继续往上看。
    InputStage earlyPostImeStage = new EarlyPostImeInputStage(nativePostImeStage);
    InputStage imeStage = new ImeInputStage(earlyPostImeStage,
            "aq:ime:" + counterSuffix);
    InputStage viewPreImeStage = new ViewPreImeInputStage(imeStage);
    InputStage nativePreImeStage = new NativePreImeInputStage(viewPreImeStage,
            "aq:native-pre-ime:" + counterSuffix);

    mFirstInputStage = nativePreImeStage;
  //这是赋值位置,可以看以上逻辑是怎么赋值earlyPostImeStage对象
    mFirstPostImeInputStage = earlyPostImeStage;
    mPendingInputEventQueueLengthCounterName = "aq:pending:" + counterSuffix;

    if (mView instanceof RootViewSurfaceTaker) {
        PendingInsetsController pendingInsetsController =
                ((RootViewSurfaceTaker) mView).providePendingInsetsController();
        if (pendingInsetsController != null) {
            pendingInsetsController.replayAndAttach(mInsetsController);
        }
    }
}

通过以上逻辑可以清晰地看到mFirstPostImeInputStage 即是ViewPostImeInputStage,我们需要跟进ViewPostImeInputStage看下对应的onProcess()方法。

 

final class ViewPostImeInputStage extends InputStage {
        public ViewPostImeInputStage(InputStage next) {
            super(next);
        }

        @Override
        protected int onProcess(QueuedInputEvent q) {
            if (q.mEvent instanceof KeyEvent) {
                return processKeyEvent(q);
            } else {
                final int source = q.mEvent.getSource();
                if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
                    return processPointerEvent(q);
                } else if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
                    return processTrackballEvent(q);
                } else {
                    return processGenericMotionEvent(q);
                }
            }
        }
...
}

以上逻辑中先判断了输入事件是键盘,还是触摸,触摸逻辑中又判断了输入源是屏幕还是trackball(我猜测这判断的是鼠标等设备输入),不过不重要,我们主要看屏幕输入的逻辑,也就是processPointerEvent(q);方法

 

private int processPointerEvent(QueuedInputEvent q) {
    final MotionEvent event = (MotionEvent)q.mEvent;

    mAttachInfo.mUnbufferedDispatchRequested = false;
    mAttachInfo.mHandlingPointerEvent = true;
    //主要看这个地方,mView即是DecorView
    boolean handled = mView.dispatchPointerEvent(event);
    maybeUpdatePointerIcon(event);
    maybeUpdateTooltip(event);
    mAttachInfo.mHandlingPointerEvent = false;
    if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
        mUnbufferedInputDispatch = true;
        if (mConsumeBatchedInputScheduled) {
            scheduleConsumeBatchedInputImmediately();
        }
    }
    return handled ? FINISH_HANDLED : FORWARD;
}

到此我需要简单做个总结,来捋一下这个流程,方便大家理解。
其实以上的mView即是DecorView。

该对象是在最开始通过PhoneWindow创建。

由WindowManager.addView(View v...)传递到WindowManagerGlobal.addView(View v..)。
然后通过ViewRootImpl.setView(View v...)传到了ViewRootImpl。

因此ViewRootImpl的变量mView即是DecorView,所以我们需要跟进DecorView.dispatchPointerEvent()
由于DecorView extends View,因此先看View.dispatchPointerEvent()

 public final boolean dispatchPointerEvent(MotionEvent event) {
        if (event.isTouchEvent()) {
            //调用dispatchTouchEvent(),而DecorView重写了dispatchTouchEvent()
            return dispatchTouchEvent(event);
        } else {
            return dispatchGenericMotionEvent(event);
        }
    }

跟进DecorView.dispatchTouchEvent()


public boolean dispatchTouchEvent(MotionEvent ev) {
    final Window.Callback cb = mWindow.getCallback();
    return cb != null && !mWindow.isDestroyed() && mFeatureId < 0
            ? cb.dispatchTouchEvent(ev) : super.dispatchTouchEvent(ev);
}

这里需要注意下这个Window.Callback cb,是通过mWindow.getCallback()获取的。

mWindow是哪来的?

这个mWindow是一个PhoneWindow对象。

是在ActivityThread.handleResumeActivity()时,通过Activity.window.getDecorView()调用PhoneWindow.installDecor() 诗 mDecor.setWindow(this);赋值的。
因此需要查看PhoneWindow.getCallback()是哪里赋值的。

在ActivityThread.prefromLuncherActivity()中,调用的Activity.attach(),此方法中对PhoneWindow的Window.Callback进行了赋值,传入的是自己。

 

 mWindow.setCallback(this);

因此,Window.Callback cb即是Activity,找到Activity.dispatchTouchEvent()

public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        onUserInteraction();
    }
    if (getWindow().superDispatchTouchEvent(ev)) {
        return true;
    }
    return onTouchEvent(ev);
}

此时事件怎么到达的Activity已经完全描述清楚,后续的流程我们就都知道了,不过我可以简单描述下。

以上方法中调用了getWindow().superDispatchTouchEvent(ev)

即是调用的PhoneWindow. superDispatchTouchEvent(ev)

PhoneWindow调用mDecor.superDispatchTouchEvent(event);

即是调用DecorView.superDispatchTouchEvent(event);

DecorView调用super.dispatchTouchEvent(event);

因为DecorView extends FrameLayout,FrameLayout extends ViewGroup,因此调用ViewGroup.dispatchTouchEvent()

通过连带调用ViewGroup.dispatchTransformedTouchEvent() 调用super.dispatchTouchEvent(event)

因为ViewGroup extends View, 因此会调用View.dispatchTouchEvent()事件又传递到了View,整个流程也就完整。

最后

在这里我也分享一份由几位大佬一起收录整理的 Flutter进阶资料以及Android学习PDF+架构视频+面试文档+源码笔记 ,并且还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料……

这些都是我闲暇时还会反复翻阅的精品资料。可以有效的帮助大家掌握知识、理解原理。当然你也可以拿去查漏补缺,提升自身的竞争力。
如果你有需要的话,可以前往 GitHub 自行查阅。

Lasso的原理及其与其他特征选择方法的比较进行阐述,然后讨论Lasso优点、缺点以及应用场景,最后给出了代码实例 在机器学习领域中,特征选择(feature selection)是指在模型训练前对数据集进行分析,选择其中有助于预测目标变量或影响模型性能的特征,去除不相关或冗余的特征,提升模型的泛化能力。而Lasso回归是一种很流行的用于特征选择的方法之一。Lasso回归(又称LASSO,least absolute shrinkage and selection operator)是一种线性模型中的特征选择方法。 阅读详情

相关推荐

桁架 拓扑优化 matlab程序_拓扑优化在结构轻量化及板壳加筋肋最优布置的应用...

1 拓扑优化简介材料的有效利用一直都是人类追求的目标,也是许多研究领域不变的话题,并伴随着结构优化理论和方法的产生而发展。结构优化设计通常分为三个层次:(1)拓扑优化:在一个确定的连续区域内寻求结构内部非实体区域位置和数量的最佳配置,寻求结构中的构件布局及节点联结方式最优化,使结构能在满足应力、位移等约束条件下,将外载荷传递到结构支撑位置,同时使结构的某种性态指标达到最优;(2)形状优化:指在保持...

weixin_39525355的博客 1878

Andriod事件分发的事件从何而来(一)

这个方法里有一个在Window创建流程的时候没有关注的InputChannel,事件真正的来源就是它,在。所以最初的事件就是从PhoneWindow进入了view的事件分发,而PhoneWindow的事件又是Activity中来的.从名字也能猜出mInputEventReceiver就是接收事件的对象了,这是一个ViewRootImpl的内部类看下它的实现。ViewRootImpl的事件就交给mView来继续分发了,这里mView是DecorView,也是在setView中传进来的。

Arthas的博客 269

从零开始:Vivado中自定义串口通信IP核的完整实现

本文详细介绍了在Vivado中从零开始实现自定义串口通信IP核的完整流程,包括Verilog核心代码编写、仿真验证、IP核封装与参数化配置技巧。通过AXI-Lite总线实现动态配置,提升FPGA开发效率,适用于各种嵌入式系统通信需求。

weixin_29274969的博客 326

Flutter android emebed 初始化过程

flutter 在android 上的启动过程

chituhuan的专栏 394

博途WinCC上位机避坑指南:从工控机选型到趋势图优化的完整流程

本文详细解析了博途WinCC上位机开发全流程,从工控机选型到趋势图优化的关键技巧。针对工业自动化场景,提供硬件配置指南、网络优化方案和性能提升策略,帮助工程师避开常见陷阱,实现稳定高效的HMI系统部署。特别强调PC Station与传统触摸屏的选型对比及SIMATIC NET配置优化。

pp12345的博客 279

OpenCV透视变换实战:5分钟搞定歪斜证件照矫正(附完整代码)

本文详细介绍了如何使用OpenCV的透视变换技术快速矫正歪斜证件照,包含完整的Python代码实现。通过特征检测、坐标计算和矩阵变换三个核心步骤,5分钟内即可将手机拍摄的歪斜图像自动矫正为专业级证件照,大幅提升图像处理效率。

weixin_29094979的博客 483

request.sendRedirect 和 request.getRequestDispatcher

request.sendRedirect和request.getRequestDispatcher  1.request.getRequestDispatcher()是请求转发,前后页面共享一个request ;  response.sendRedirect()是重新定向,前后页面不是一个request。  2.RequestDispatcher.forw

wfh6732的博客 1216

Arduino智能小灯DIY:人体感应+光线感应+蓝牙控制全攻略(附完整代码)

本文提供了一份完整的Arduino智能小灯DIY制作指南。项目融合了人体感应、光线感应与蓝牙控制三大功能,通过详细的硬件清单、电路连接图、核心逻辑讲解及附带的完整代码,手把手教你打造一个能自动感知环境与人、并支持手机远程控制的智能照明装置,是入门智能家居和物联网开发的绝佳实践。

java5的博客 1094

关于request.RequestDispatcher()方法

RequestDispatcher对象从客户端获取请求request,并把它们传递给服务器上的servlet,html或jsp。它有两个方法: 1.void forward(ServletRequest request,ServletResponse response)–请求转发 用来传递request的,可以一个Servlet接收request请求,另一个Servlet用这个request请 求来产生response。request传递的请求,response是客户端返回的信息。forward要在resp

qq_51730795的博客 519

PICO640红外探测器配置模块verilog

Ulis pico 640红外探测器配置模块

Go Forward Forever! 2034

lammps后处理:堆垛层错和孪晶的数量统计

python调用ovito包可以免费实现ovito pro版本的功能,不需要安装ovito pro软件,如统计位错线长度、CNA结构、键角分布等,如需深入学习,可考虑报名python ovito后处理课程,或lammps一对一课程。lammps金属变形模拟中,可能会产生堆垛层错或者孪晶等结构,但是ovito免费版本无法统计这些结构的数量。使用python和ovito软件包,则可以方便的统计出这些结构的数量。大家好,我是小马老师。

lammps_jiayou的博客 469

android inset 管理

android 11上新增一套inset管理方法。Insets 是指系统边衬区的窗口, 包括statusbar, navigation bar, 输入法等, 都在insets管理中。下面说的这些insets即为这些窗口。通过insets相关的接口, app可以控制insets窗口的显示, 隐藏, 沉浸式等。inset 最基本的控制是show 和hide。在inset 不同的状态下, 应用区的位置也会发生变化, 这部分的计算也是inset控制的重要内容之一。

april_12345的博客 6143

AgentScope实战训练营:构建计划可视化管理和HITL的AI智能计划助手

本文基于AgentScope Java SDK和Spring Boot WebFlux,从零构建一个支持SSE流式对话、计划可视化管理和HITL的AI智能计划助手Web应用PlanNotebook。涵盖项目架构设计、ReActAgent初始化、自定义工具注册、Hook机制实现、SSE事件协议定义、前端流式渲染等核心技术点,提供完整可运行的代码示例和详细的REST API参考。

program哲学 400

2024年安卓最全那天有人问我,Android 的事件到底是怎么来的?,阿里巴巴四面面试

现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水!为什么某些人会一直比你优秀,是因为他本身就很优秀还一直在持续努力变得更优秀,而你是不是还在满足于现状内心在窃喜!Android架构师之路很漫长,一起共勉吧!} else {

2401_84520332的博客 292

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Android事件分发完全解析之为什么是她

记得以前教我code的启蒙老师对我说过,如果你想学习一个新事物只需要三个W:Why、What、How,也就是:为什么?是什么?怎么做?当你搞懂这三个W之后,你对新事物必定会有一个透彻的了解。然而对大多数Student来说他们往往最有兴趣的是“How”也是他们最先接触的一个W,其次则是“What”,而“Why”往往会被选择性地忽略,这也是很多时候我们为什么无法将现有知识水平提升一个层次的根本原因。

AigeStudio 1万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

android 提醒,Android 添加提醒事件

代码如下:private void addCalender() {if (Build.VERSION.SDK_INT >= 8) {calanderURL = "content://com.android.calendar/calendars";calanderEventURL = "content://com.android.calendar/events";calanderRemider...

weixin_39701288的博客 461

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

面试:事件拦截相关问题

1、view在执行dispatchTouchEvent的时候先要去判断该view是否有touchListener和执行TouchListener的onTouch方法的返回值。2、TouchListener的onTouch方法返回false,事件继续传递在dispatch方法中调用了同级的onTouchEvent方法3、然后在onTouchEvent方法中的UP事件中判断是否注册有onClickListener,有就执行onclick方法。android中的事件传递和处理机制 - fuly - 博客园。

王温暖的博客 884

Android事件分发机制深度解析:从原理到实战解决滑动冲突

在Android应用开发中,触摸事件处理是构建流畅交互体验的核心基础。其本质是一套基于View树的事件传递与响应机制,涉及事件分发、拦截与消费三个关键环节。理解这套机制的技术价值在于,它能帮助开发者精准控制用户操作的响应逻辑,避免常见的滑动冲突、点击穿透等问题,从而提升应用的整体交互质量。在具体应用场景中,无论是处理ScrollView内嵌ListView的经典滑动冲突,还是实现自定义ViewGroup的复杂手势交互,深入掌握事件分发原理都是实现预期效果的前提。本文结合ViewGroup、onInterce

weixin_30381317的博客 1057

如何半个小时快速完成安卓开发大作业?

首先我需要向你致歉,这次确实有些标题党的意味了。 当你点进来的时候我可以大致判断一下,你应该是这样的! 安卓开发课没有认真听过一节 Android Studio此刻都没有安装 现在想用别人的代码套个皮肤也懒得动 在昨天的时候,刘通老师在QQ群里面提到了一下要求 害怕查重就写成设计报告格式,如:xxx设计报告 总体设计思路: 界面布局设计: 类的主要成员: 初始化(成员与界面组件的关联): 播放文件(音乐文件的存储,数组,下标等): 事件监听器设计(这是核心和主题): 播放控制:

Bamboo 2万+

Android事件注入:从adb input到无障碍服务的自动化测试实战

在移动应用自动化测试与辅助功能开发中,模拟用户操作是核心需求。其基本原理是通过程序向系统注入输入事件,替代真实硬件交互。从技术价值看,这不仅是自动化测试脚本稳定执行的基础,更是实现无障碍服务、远程控制等高级功能的关键。在Android生态中,事件注入主要通过系统服务层实现,涉及InputManagerService与权限控制机制。具体到应用场景,开发者常从adb shell input命令入门,但其存在事件分发层级与坐标适配等局限。为突破这些限制,需深入理解INJECT_EVENTS权限路径与无障碍服务框架

weixin_34268169的博客 495

android 广告 刷量,网易新闻客户端在安卓商店刷量被惩罚

Bianews独家报道 7月10日消息,知情人士向Bianews独家透露,新闻客户端在某安卓应用商店因存在多次数量而被官方减量惩罚,单次额度在200万用户左右。我们从某安卓应用商店注意到,某一天时间内,网易新闻客户端突然“掉粉”,消息人士透露,这是因为作弊刷量被官方减量。两张对比图很明显看出,短时间内装机量暴跌近200万我们再来看另外两张图,这是网易新闻客户端在近一个月内在某应用商店总下载量走势与...

weixin_31881651的博客 278
上一篇: Android | 作用域存储适配
下一篇: 不吹不黑,“滴滴”我是绝对不会去的——年前跑路的我如何面试?
懂你的大海
博客等级 码龄6年 9049粉丝 1381原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值