0
A
回答
-2
运行此对话框(或例如吐司消息)
// WRITE
File f_cache = (activity_name).this.getCacheDir();
f_cache_path = f_cache.getAbsolutePath();
OutputStream title_stream = null;
File title_forsave = new File(f_cache_path + File.separator + "info.txt");
title_stream = new FileOutputStream(title_forsave);
title_stream.flush();
title_stream.close();
// READ
FileInputStream title_in = new FileInputStream(f_cache_path + File.separator + "info.txt");
//和所有
时,您可以保存缓存目录文件//read
FileInputStream title_in = new FileInputStream(f_cache_path + File.separator + "info.txt");
if (title_in != null) {
title_in.close();
} else {
YOUR DIALOG FUNCTION (OR OTHER)
// write
File f_cache = (activity_name).this.getCacheDir();
f_cache_path = f_cache.getAbsolutePath();
OutputStream title_stream = null;
File title_forsave = new File(f_cache_path + File.separator + "info.txt");
title_stream = new FileOutputStream(title_forsave);
title_stream.flush();
title_stream.close();
}
- 用户可以在需要时清除缓存并再次查看您的功能。
6
试试这个,不需要数据库或文件流等
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main):
SharedPreferences prefs = getSharedPreferences(filename, 0);
boolean runOnce = prefs.getBoolean("ranOnce", false);
if (runOnce == false){
//dialog code here
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("ranOnce", true);
editor.commit();
}
//normal onCreate code here
}
它建立了一个SharedPreference,这将是错误的开始。如果它是假的,它将运行对话框代码,然后将其自身设置为true。一旦成功,它将不会在下次应用程序启动时运行对话框代码。
+1
它的工作原理!非常感谢你。 – user1114971 2011-12-25 09:31:11
相关问题
- 1. 如何在第一次应用程序启动时显示pushviewcontroller?
- 2. 当应用程序/活动启动时显示对话框
- 3. 仅在第一次启动应用程序时显示UIAlertView
- 4. 如何仅显示一次活动一次。应该只显示第一次打开的应用程序。?
- 5. 当应用第一次启动时显示幻灯片教程
- 6. 仅在应用程序第一次启动时启动活动
- 7. 应用程序第一次在应用程序启动后显示白屏的应用程序
- 8. 通用Windows应用程序显示为对话框页面
- 9. 推送通知每次在应用程序启动时显示
- 10. 如何在Mac上启动“选择应用程序”对话框?
- 11. 如何在首次启动应用程序时显示UIViewController?
- 12. 如何在我的应用程序第一次运行时才显示警报对话框?
- 13. 如何在显示对话框后关闭应用程序?
- 14. 显示设置并在第一次启动应用程序时记住
- 15. iPhone应用程序第一次启动时显示操作表iOS 8
- 16. 在第一次启动iPhone应用程序时显示信息imageview
- 17. 显示Google Play游戏所有应用程序启动的欢迎对话框
- 18. Android启动应用程序显示“可以修改系统设置”对话框
- 19. 批次:启动应用程序不会显示一个GUI
- 20. 启动时WPF显示对话框
- 21. 想要在应用程序安装后仅显示一次对话框
- 22. 如何显示应用程序启动对话做轻按按钮
- 23. 如何通过使用mfc应用程序的对话框移动按钮
- 24. 如何在应用程序关闭时单击通知时显示对话框
- 25. 启动应用程序通话
- 26. Javascript - 如何在第一次显示后禁用打印对话框?
- 27. 第一次启动第三方应用程序时会收到通知
- 28. jQuery ui对话框只显示一次
- 29. 通过显示另存为对话框
- 30. 电话应用程序顶部的显示对话框:Android
先尝试阅读教程。 – 2011-12-25 00:12:11