unity安卓被系统杀死怎么重启

unity安卓被系统杀死怎么重启,第1张

实现步骤:

1、新建一个 AndroidLibrary。

2、取一个名称。

3、在模块中创建一个脚本,编写重启应用的代码逻辑。

/**

* 多少毫米后重启程序,大于200毫米

* @param Ntime 200

*/

public void doRestart(int Ntime)

{

if(Ntime<200)Ntime=200

Log.d("Unity", "========restart "+Ntime)

Intent restartIntent = getPackageManager()

.getLaunchIntentForPackage(getPackageName() )

PendingIntent intent = PendingIntent.getActivity(this, 0,

restartIntent, Intent.FLAG_ACTIVITY_CLEAR_TOP)

AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE)

manager.set(AlarmManager.RTC, System.currentTimeMillis()+Ntime, intent)

finish()

android.os.Process.killProcess(android.os.Process.myPid())

}

以上是unity调用android原生方法重启游戏,更多unity插件,就在纳金论坛查看。

强制结束。unity引擎是一个可以在线运行的模型渲染动画软件,软件在使用过程中突然重启会导致软件强制结束,结束后先前的资料都会清空,因此重启后所有未保存的内容都会消失,这是无法恢复的。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11886352.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存