我有一个android库项目并在Unity项目中导入了库项目.现在,我想在Unity项目中实现一个回调,它将根据android库项目给出的响应执行.我的意思是说,来自UnityPlayerActivity(Android Project)的Call Script File方法.
目前我使用下面的代码行但没有任何反应:
UnityPlayer.UnitySendMessage("Main Camera","showMessage",errorMessage);
Run Code Online (Sandbox Code Playgroud)
Main Camera是我的游戏对象.showMessage是脚本文件中的消息名称.
Message是通过Android Activity在Unity中显示的消息.
请检查我的下面代码Unity Script File和Android Activity.
Unity脚本文件:
using UnityEngine;
using System.Collections;
public class scriptfile : MonoBehaviour {
// Use this for initialization
void Start () {
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
jo.Call("shareText","236","236");
}
void showMessage(string message){
print ("hello");
Debug.Log ("hello");
}
}
Run Code Online (Sandbox Code Playgroud)
Android文件UnityPlayerActivity:
/**
* Created by CH-E01073 on 28-09-2015.
*/
public class MainAct extends UnityPlayerActivity implements RegistrationListener,BOffersListener {
Context context;
SharedPreferences prefs …Run Code Online (Sandbox Code Playgroud) 我收到了来自Google的电子邮件,主题如下: Google Play Warning: SSL Error Handler Vulnerability". In this email, Google explains that my app has an ["unsafe implementation of the WebViewClient.onReceivedSslError handler"
这是我的方法实现(WebView Client):
public class MyBrowser extends WebViewClient {
boolean timeout;
public MyBrowser() {
timeout = true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
try {
progressBar.setVisibility(View.VISIBLE);
}catch(Exception e){
e.printStackTrace();
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
try{
progressBar.setVisibility(View.GONE); …Run Code Online (Sandbox Code Playgroud) 我正在研究android中的一个库项目.我想将我的库上传到JCenter.我创建了bintray帐户等,并按照此处提到的所有步骤进行操作.
我在应用程序模块和库模块中进行了以下更改.
应用程序模块build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.testapp"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':testlib')
}
Run Code Online (Sandbox Code Playgroud)
库模块build.gradle
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'test-sdk'
publishedGroupId = 'in.test.sdk'
libraryName = 'testlib'
artifact = 'test-sdk'
libraryDescription = 'A …Run Code Online (Sandbox Code Playgroud) 我正在研究android中的一个库项目.我想将我的库上传到JCenter.我创建了bintray帐户等,并按照此处提到的所有步骤进行操作http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
我在应用程序模块和库模块中进行了以下更改.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.testapp"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':testlib')
}
Run Code Online (Sandbox Code Playgroud)
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'test-sdk'
publishedGroupId = 'in.test.sdk'
libraryName = 'testlib'
artifact = 'test-sdk'
libraryDescription = 'A wrapper …Run Code Online (Sandbox Code Playgroud)