我试图将简单的Unity形状图集成到使用Android Studio IDE进行显示,但它显示如下:
您的硬件不支持此应用程序抱歉
我的手机是Android 6.0 Marshmallow,Unity的版本是5.4.1f1
Android Studio中的logcat没有显示任何错误,除非我关闭不支持的硬件消息,然后崩溃。
package com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.maps_class;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.R;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.SplashInterface;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.comic_class.comiclass;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.phone_class.phoneclass;
import com.cs4.android_lcitresearch.schoolsafetyemergencyapplication.scenario_class.scenarioclass;
import com.unity3d.player.UnityPlayer;
public class lcoldclass extends AppCompatActivity {
protected UnityPlayer mUnityPlayer;
public static Context mContext;
private Handler handler=new Handler();
public FrameLayout fl_forUnity;
public ImageButton scenario1, comic1, phoneclass1, maps1, homeb;
public Toolbar toolbar;
public TextView txttitle;
public void init_home() {
homeb= (ImageButton)findViewById(R.id.homebutton);
homeb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,SplashInterface.class);
startActivity(first);
}
});
}
public void init_scenario() {
scenario1= (ImageButton)findViewById(R.id.scenario);
scenario1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,scenarioclass.class);
startActivity(first);
}
});
}
public void init_comic() {
comic1= (ImageButton)findViewById(R.id.comicbutton);
comic1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,comiclass.class);
startActivity(first);
}
});
}
public void init_phone() {
phoneclass1= (ImageButton)findViewById(R.id.callbutton);
phoneclass1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,phoneclass.class);
startActivity(first);
}
});
}
public void init_maps() {
maps1= (ImageButton)findViewById(R.id.mapsl);
maps1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent first = new Intent(lcoldclass.this,SecondInterfaceF.class);
startActivity(first);
}
});
}
private void initToolbar() {
toolbar = (Toolbar) findViewById(R.id.include2);
toolbar.showOverflowMenu();
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
mContext = this;
getWindow().takeSurface(null);
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
getWindow().setFormat(PixelFormat.RGB_888);
mUnityPlayer = new UnityPlayer(this);
if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mUnityPlayer.init(glesMode, trueColor8888);
View playerView = mUnityPlayer.getView();
setContentView(R.layout.lcmapsold1);
this.fl_forUnity = (FrameLayout)findViewById(R.id.frameunity);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(750, 630);
fl_forUnity.addView(playerView, 0, lp);
initToolbar();
init_home();
init_scenario();
init_comic();
init_phone();
init_maps();
txtformation_init();
mUnityPlayer.requestFocus();
}
///////////////////////////// Unity Codes Override///////////////////////////////////////////
// Quit Unity
@Override protected void onDestroy ()
{
mUnityPlayer.quit();
super.onDestroy();
}
// Pause Unity
@Override protected void onPause()
{
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
@Override protected void onResume()
{
super.onResume();
mUnityPlayer.resume();
}
// This ensures the layout will be correct.
@Override public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Notify Unity of the focus change.
@Override public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
// For some reason the multiple keyevent type is not supported by the ndk.
// Force event injection by overriding dispatchKeyEvent().
@Override public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.injectEvent(event);
return super.dispatchKeyEvent(event);
}
// Pass any events not handled by (unfocused) views straight to UnityPlayer
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onTouchEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
/*API12*/ public boolean onGenericMotionEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
///////////////////////////// Unity Codes Override///////////////////////////////////////////
}
如何解决?我无法理解用户如何在没有集成问题的情况下管理该程序。