开发者

Change main activity in code

开发者 https://www.devze.com 2023-02-11 18:06 出处:网络
How to change main activity at application startup in Android? I want to implement lock screen asking for password, before allow user to interact with application. Password 开发者_运维问答screen can

How to change main activity at application startup in Android?

I want to implement lock screen asking for password, before allow user to interact with application. Password 开发者_运维问答screen can be turned of in application's settings and in such case (when application should not ask for password) I want to start Main application activity not Password activity. How it is possible?


In the onCreate of the Main activity, check preference and if password is on startActivity to load the Password activity.


First, I am new to Android programming so bear with me!

If I was doing it, I would have created another activity that would be the main activity (set in the AndroidManifest.xml file) and inside the onCreate() event I would have checked that parameter in your setting file and depending on its value, I would have launched the password activity or the other one.

0

精彩评论

暂无评论...
验证码 换一张
取 消