Page 480 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 480

public  NotificationService()  {

                }



                @Override
                public  IBinder  onBind(Intent  intent)  {
                    return  null;

                }



                protected boolean  mRunning;


                @Override

                public  int  onStartCommand(Intent  intent,  int  flags, int startld)  {
                    SharedPreferences test  =  getSharedPreferences("test",  MODE_PRIVATE);



                    hostname  =  "192.168.0.15";
                    t_flag  =  test.getString("flag",  "0");  //t_flag변수에  SharedPreferences의

            flag값을  넣음



                    new Thread(new  Runnable()  {
                        @Override
                        public  void run()  {

                            try {
                                socket  =  new  Socket(hostname, Port);

                                outstream                                   =                           new
            DataOutputStream(socket.getOutputStream());



                                 //소켓연결  및  잠궜다or풀었다는  신호  보내기
                                outstream.writeChar(t_flag.charAt(0));

                                outstream.flush();


                                if  (t_flag.equals("0"))  {

                                    outstream.close();
                                    socket.close();





                                                         -  473  -
   475   476   477   478   479   480   481   482   483   484   485