有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    您可以很容易地使用SharedPreferences来实现这一点。试着做一些类似的事情:

    final String PREF_NAME = "MyPref";
    
    // getting saved preferences
    SharedPreferences settings = getSharedPreferences(PREF_NAME, 0);
    
    if (settings.getBoolean("my_first_time", true)) {
        //the app is being launched for first time, do something        
        Log.d("Comments", "First time");
    
                 // first time task
                 runUserAgreements();
    
        // record the fact that the app has been started at least once
        settings.edit().putBoolean("my_first_time", false).commit(); 
    }
    

    然后声明一个名为runUserAgreements()的函数并运行一个显示用户协议和内容的活动或对话框

    编辑:

    我建议将上述代码放在扩展Application的类中 要检查默认活动中通常不包含的firstrun:

    public class MyApp extends Application {
        @Override
        public void onCreate() {
            super.onCreate();
    
            // CODE HERE
    
        }
    }
    

    不要忘记调用AndroidManifest中的类。xml:

    <application android:name=".MyApp"
                 android:label="@string/app_name"
                 .
                 .
                 ...>
    ....
    </application>
    
  2. # 2 楼答案

    看看Google的iosched项目示例,特别是这个活动:Welcome Activity。我觉得它的UI设计也很不错