Android 与Unity交互之Toast消息
Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
这一句代码不能直接放在
public void ShowMessage(String msg){
Log.e("-------", msg);
// And this is how you call it from the worker thread:
Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
}
来接收Unity发送过来的消息。
具体是这样的,在继承UnityPlayerActivity或UnityNativePlayerActivity的Activity中:
在onCreate中加入下列代码: (需要import android.os.Message;)
//处理事件
mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message message) {
// This is where you do your work in the UI thread.
// Your worker tells you in the message what to do.
if(message.what == 1111){
Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();
}
}
};
然后在类体中加入
public void ShowMessage(String msg){
Log.e("-------", msg);
// And this is how you call it from the worker thread:
Message message = mHandler.obtainMessage( 1111,msg);
message.sendToTarget();
}
Android 与Unity交互之Toast消息的更多相关文章
- Android与Unity交互研究
转载请注明出处:http://blog.csdn.net/crazy1235/article/details/46733221 Android与Unity交互研究 unity与android交互的由来 ...
- Android应用开发学习之Toast消息提示框
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 本文我们来看Toast消息提示框的用法.使用Toast消息提示框一般有三个步骤: 1. 创建一个Toast对象.可 ...
- Unity 3D与Android Studio安卓交互之-导出jar包
u3d与安卓 jar 包交互 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享 ...
- Unity与Android之间的交互之AndroidManifest
https://blog.csdn.net/qq_15003505/article/details/70231975 AndroidManifest,中文名一般称之为清单文件.它描述了应用程序的组件的 ...
- Unity与Android的相互交互
1.Unity调用Android. Unity块代码: using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.play ...
- 【Android代码片段之六】Toast工具类(实现带图片的Toast消息提示)
转载请注明出处,原文网址:http://blog.csdn.net/m_changgong/article/details/6841266 作者:张燕广 实现的Toast工具类ToastUtil封装 ...
- Android Toast 封装,避免Toast消息覆盖,替换系统Toast最好用的封装
Android Toast 封装,避免Toast消息覆盖,无阻塞,等强大功能 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
- Android向unity发送消息
有些时候需要Android向unity发送消息,有两种方法实现,一.通过unity再带的消息机制,二.通过注册回调的方式. 一.通过UnityPlayer.UnitySendMessage():方法 ...
- Android与H5交互(java与js的交互)
一.理论概述 1.js调用java方法 直接调用WebView的该方法就可以添加接口了,不过先要启动交互 // 启用javascript mWebView.getSettings().setJavaS ...
随机推荐
- centos7安装redis
方法一:使用命令安装(前提是已经安装了EPEL). 安装redis: yum -y install redis 启动/停止/重启 Redis 启动服务: 1 systemctl start redis ...
- Eclipse中全局搜索和更替
Eclipse全局搜索步骤 使用快捷键"ctrl+H"打开文件搜索对话框,选择"File Search"标签,在Containing text中输入你需要搜索 ...
- BIEE 10g 二次开发整理
近半年在公司做某个项目的时候,主要使用到了Oracle BIEE 10g这套工具.刚开始的时候,对OBIEE是七窍通了六窍,还是一窍不通. 现在已经摸索出些许门道,特整理出来:一来,备忘:二来,供大家 ...
- window内容
window parent top location.href location.reload location.replace
- hexo deploy出错的解决方法
.ERROR Deployer not found: git 执行npm install hexo-deployer-git --save .$ hexo d INFO Deploying: git ...
- C#中XML和json互相转换
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xm ...
- 为什么.Net要求序列化的类必须有一个无参数的构造函数
刚才用xml序列化器,序列化一个类,结果报错说序列化的类必须带有一个无参的构造函数,好奇怪啊.为什么要有这么苛刻的条件,而且xml序列化还要求序列化的成员是public. 我以前一直觉得序列化器是一个 ...
- iOS沙盒(sandbox)
iOS沙盒 每个ios应用都有自己的应用沙盒,应用沙盒就是文件系统目录,默认下iOS应用只能访问自己的沙盒 extenaion是iOS8新开放的一种对几个固定系统区域的扩展机制,它可以在一定程度上弥补 ...
- 使用centos引导内核错误:kernel: pnp 00:0b: can't evaluate _CRS: 8
CentOS系统在开机过程中,一直遇到黑屏提示:“kernel: pnp 00:0b: can't evaluate _CRS: 8”,不理会它仍能启动系统并正常工作,未知何故. 经查,这是内核引导的 ...
- 安装 node-sass 的正确姿势
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass