2017-12-26 15 views
0

私のアプリでgithubのライブラリを実装しました。最初の起動後に無効にする方法を知りたい。私はそれがアプリの起動時に毎回表示されたくない。私は何を試したのheres。私はブール変数を追加しようとしましたが、それは動作しませんでした。 この質問はこのトピックのためだけではありません。アプリのインストール後最初にメソッドを呼び出す必要があるとします。最初のアプリケーションの起動時に呼び出された後に再び呼び出されることはありません。私は達成しようとしていることがはっきりしていることを願っています。最初の起動アクティビティを無効にする

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; 
+0

最初に起動すると、SharedPreferenceのbooleanを作成し、あなたのロジックを制御し、それに応じての – rafid059

+0

可能な重複ブール値を更新するためにそれを使用[アプリが初めて開かれたときに一度だけの活動を起動する方法を?]( https://stackoverflow.com/questions/7238532/how-to-launch-activity-only-once-when-app-is-opened-for-first-time) – rafid059

+0

これは正確な行動ではない、それは "方法 "私は最初の起動後に無効にしたい – user8747695

答えて

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

    if (firstLoad) { 

     //call your method 

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

    } 
関連する問題