繁体   English   中英

禁用首次启动活动

[英]Disable first launch activity

我已经在我的应用程序中从github实现了一个库。 我想知道在首次启动后如何禁用它。 我不希望每次应用启动时都显示它。 这是我尝试过的。 我尝试添加布尔变量,但没有成功。 这个问题不仅仅针对这个主题,假设我想在应用程序安装后仅在第一次之后调用一个方法,我不希望它在首次启动应用程序时被再次调用。 我希望很清楚我要实现的目标。

 boolean firstLoad;

    if(firstLoad=true) {

        TapTargetView.showFor(this,                 // `this` is an Activity
                TapTarget.forView(findViewById(R.id.button), "This is a target", "We have the best targets, believe me")
                        // All options below are optional
                        .outerCircleColor(R.color.colorPrimary)      // Specify a color for the outer circle
                        .outerCircleAlpha(0.96f)            // Specify the alpha amount for the outer circle
                        .targetCircleColor(R.color.colorAccent2)   // Specify a color for the target circle
                        .titleTextSize(20)                  // Specify the size (in sp) of the title text
                        .titleTextColor(R.color.colorAccent2)      // Specify the color of the title text

                new TapTargetView.Listener() {          // The listener can listen for regular clicks, long clicks or cancels
                    @Override
                    public void onTargetClick(TapTargetView view) {
                        super.onTargetClick(view);      // This call is optional

                    }
                });
    }

    firstLoad=false;
 Boolean firstLoad = getSharedPreferences("PREFERENCE", MODE_PRIVATE)
            .getBoolean("firstLoad", true);

    if (firstLoad) {

        //call your method

        getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit().putBoolean("firstLoad", false).commit();

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM