[英]How can I make my apk to function only if my device has a txt file?
How can I make my apk to function only if my device has a txt file? 仅当设备具有txt文件时,我才能使apk起作用吗? I have an apk that I have made. 我有一个APK。
Is there a way to make it work only if the device its installed on has a specific text file which I can input anything in and it won't work if the device doesn't have the file. 只有安装了该设备的设备具有特定的文本文件(我可以在其中输入任何内容)时,才可以使它工作,如果该设备没有该文件,该文件将无法工作。
You can check for your file in onCreate
method of your launcher activity. 您可以在启动器活动的onCreate
方法中检查文件。 If the file exists, you can do whatever you want like creating an intent to MainActivity
and if it does not exist, you can finish your app : 如果该文件存在,则可以执行任何操作,例如为MainActivity
创建意图;如果该文件不存在,则可以完成您的应用程序:
File file = new File(filePath);
if(file.exists()) {
// Do Something
}
else {
// Close the app
finish();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.