好友
阅读权限10
听众
最后登录1970-1-1
|
1.Android Stidio 新建Android项目 选择 Empty Activiy
2.右键项目选择 New Module——Android Library Package name=Unity项目包名
3.根据业务需求 在包名根目录下 建立相应的Appliaction/Activity类 并实现onCreate方法 如
-----------------------------------------------------------------------------------------------
Class MyAppliaction extends Application{
@Overridepublic void onCreate() { super.onCreate(); MobSDK.init(this, this.getAppkey(), this.getAppSecret()); UMU3DCommonSDK.init(this, "xxxxxxxxxxxxx", "Umeng", UMConfigure.DEVICE_TYPE_PHONE,""); UMU3DCommonSDK.setLog(true);}
}
---------------------------------------------------------------------------------------------
public class MainActivity extends UnityPlayerNativeActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }
---------------------------------------------------------------------------------------------
//unity调用的方法 public void doRestart(int Ntime){ Intent restartIntent = getPackageManager() .getLaunchIntentForPackage(getPackageName() ); PendingIntent intent = PendingIntent.getActivity(this, 0,restartIntent,0); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.set(AlarmManager.RTC, System.currentTimeMillis()+Ntime, intent); finish(); android.os.Process.killProcess(android.os.Process.myPid()); }}
当需要继承UnityPlayerNativeActivity 时 需要引入Unity安装根目录下的classes.jar
Data->PlaybackEngines->androidplayer->Variations->mono->release->classes->classes.jar
-----------------------------------------------------------------------------------------
4.使用Gradle build library项目
进入项目\build\intermediates\classes\release\包名\
C:/Users/Administrator/AppData/Local/YNote/data/qq34F7EF5B9522FF98678F37FDDDF8FF29/d5580a86ffde4250b78adcb0bd9f7868/078077978_hd.png
删除多余的class文件
然后回到release目录下
打开命令行 运行 jar cvf library.jar ./com 生成jar包 |
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|