android11 native looper的用法

#include <chrono>
#include <thread>
#include <utils/Trace.h>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <thread>
#include <iostream>
#include <stdint.h>
#include <sys/types.h>
#include <utils/Looper.h>
#include <time.h>
#include <unistd.h>
#include <utils/Looper.h>
#include <utils/StopWatch.h>
#include <utils/Timers.h>
#include <thread>
#include <utility>
#include <utils/threads.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>

using namespace std;
using namespace android;

int main(int, const char**) {
	sp <Looper> looper = new Looper(false);
		while (1) {
			cout << "pollOnce" << endl;
			int result = looper->pollOnce(1000*2);
		}
	cout << "end" << endl;
	return 0;
}


在pollOnce的过程中,可以调用 wake方法唤醒它。这个就是android上层发消息的处理。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Process: com.android.systemui, PID: 12501 C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in com.android.systemui.qsview.signal.SignalUtils$1@dbb3275 C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1830) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8061) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:703) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911) C1C4B8B 06-09 16:11:31.132 12501 12501 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Pid 12501 has exceeded the number of permissible registered listeners. Ignoring request to add.
06-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值