Page 377 - MDP2022-2
P. 377

actionBar.hide();
            Button  Start_btn  =  findViewById(R.id.Start_btn);
            Button  storage_btn  =  findViewById(R.id.storage_btn);
            Button  logOut  =  findViewById(R.id.logOut);
            Start_btn.bringToFront();
            storage_btn.bringToFront();
            logOut.bringToFront();
            intent  =  getPackageManager().getLaunchIntentForPackage(packageNames);
            Start_btn.setOnClickListener(new  View.OnClickListener()  {
            @Override
            public  void  onClick(View  view)  {
            try  {
            Toast.makeText(ComActivity.this,  "기기와  통신을  시작합니다.",  Toast.LENGTH_SHORT).show();
            Intent  intent  =  getPackageManager().getLaunchIntentForPackage("com.example.mybluetooth");
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent);
            finish();
            }catch  (Exception  e){
            Vibrator  vibrator  =  (Vibrator)  getSystemService(Context.VIBRATOR_SERVICE);
            if(Build.VERSION.SDK_INT  >=  26)  {
            vibrator.vibrate(VibrationEffect.createOneShot(1500,  10));
            }  else  {
            vibrator.vibrate(1500);
            }
            }
            }
            });

            storage_btn.setOnClickListener(new  View.OnClickListener()  {
            @Override
            public  void  onClick(View  v)  {
            Intent  intent  =  new  Intent(ComActivity.this,  storageActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent);
            finish();
            }
            });
            logOut.setOnClickListener(new  View.OnClickListener()  {
            @Override
            public  void  onClick(View  view)  {
            auto  =  getSharedPreferences("autoLogin",  Activity.MODE_PRIVATE);
            editor  =  auto.edit();
            editor.clear();
            editor.commit();
            Toast.makeText(getApplicationContext(),"로그아웃",Toast.LENGTH_SHORT).show();
            Intent  tent  =  new  Intent(ComActivity.this,  LoginActivity.class);
            tent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(tent);
            finish();
            }
            });
            }
            int  BackConfirm  =  0;
            @Override
            public  void  onBackPressed()  {
            if(BackConfirm  >=  1)  {
            Toast.makeText(this,  "로그인  화면으로  돌아갑니다",  Toast.LENGTH_SHORT).show();
            Intent  intent  =  new  Intent(ComActivity.this,  LoginActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent);
            finish();
            }
            BackConfirm++;
            }
            }

            Splash  Activity  -
            import  android.content.Intent;
            import  android.os.Bundle;
            import  android.os.Handler;
            import  androidx.appcompat.app.ActionBar;
            import  androidx.appcompat.app.AppCompatActivity;
   372   373   374   375   376   377   378   379   380   381   382