uses or overrides a deprecated API Recompile with -Xlint: deprecation for details

0
  

C: \ Users \ danil \ AndroidStudioProjects \ ApplicationDrive \ app \ src \ main \ java \ danilo \ cursoandroid \ com \ applicationid \ WelcomeActivity.java:
  uses or overrides a deprecated API.
  Recompile with -Xlint: deprecation for details.

My app at the time of opening "APP stopped"

Code

package danilo.cursoandroid.com.aplicativoidoso;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class WelcomeActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private LinearLayout layoutDot;
    private TextView[]dotstv;
    private int[]layouts;
    private Button btnSkip;
    private Button btnNext;
    private MyPagerAdapter pagerAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);



        if (!isFirtTimeStartApp()){
            startMainActivity();
            finish();

        }

        setStatusBarTransparent();

        setContentView(R.layout.activity_welcome);

        viewPager = findViewById(R.id.view_pager);
        layoutDot = findViewById(R.id.dotLayout);
        btnNext = findViewById(R.id.btn_next);
        btnSkip = findViewById(R.id.btn_skip);

        //Usuario pressionar skip, começa Main Activity
        btnSkip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                startMainActivity();
            }
        });
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int currentPage = viewPager.getCurrentItem()+1;
                if (currentPage < layouts.length){
                    //movimentando para proxima page
                    viewPager.setCurrentItem(currentPage);

                }else {
                    startMainActivity();
                }

            }
        });
        layouts = new int[]{R.layout.slider_1,R.layout.slider_2,R.layout.slider_3,R.layout.slider_4};
        pagerAdapter = new MyPagerAdapter(layouts,getApplicationContext());
        viewPager.setAdapter(pagerAdapter);

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
                if (i == layouts.length-1){
                    //começo page
                    btnNext.setText("Começar");
                    btnSkip.setVisibility(View.GONE);

                }else {
                    btnNext.setText("Próximo");
                    btnSkip.setVisibility(View.VISIBLE);
                }
                setDotStatus(i);

            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
        setDotStatus(0);


    }
    private boolean isFirtTimeStartApp(){
        SharedPreferences ref = getApplicationContext().getSharedPreferences("IntroSliderApp",Context.MODE_PRIVATE);
        return ref.getBoolean("FirtTimeStartFlag",true);
    }

    private void setFirtTimeStartStatus(boolean stt){
        SharedPreferences ref = getApplicationContext().getSharedPreferences("IntroSliderApp",Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = ref.edit();
        editor.putBoolean("FirtTimeStartFlag", stt);
        editor.commit();
    }


    private void setDotStatus(int page){
        layoutDot.removeAllViews();
        dotstv = new TextView[layouts.length];
        for (int i = 0; 1 < dotstv.length; i++){
            dotstv[i] = new TextView(this);
            dotstv[i].setText(Html.fromHtml("&#8226"));
            dotstv[i].setTextSize(30);
            dotstv[i].setTextColor(Color.parseColor("#a9b4bb"));
            layoutDot.addView(dotstv[i]);
        }
        //set atual ativo
        if (dotstv.length>0){
            dotstv[page].setTextColor(Color.parseColor("#ffffff"));

        }
    }
    private  void startMainActivity(){
        setFirtTimeStartStatus(true);
        startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
        finish();
    }

    private  void setStatusBarTransparent(){
        if (Build.VERSION.SDK_INT >= 21){
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN);
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        }

    }
}
    
asked by anonymous 25.09.2018 / 08:41

0 answers