Ejemplo n.º 1
0
  public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    // If your preview can change or rotate, take care of those events here.
    // Make sure to stop the preview before resizing or reformatting it.

    if (mHolder.getSurface() == null) {
      // preview surface does not exist
      return;
    }

    // stop preview before making changes
    try {
      mCamera.stopPreview();

      Log.v(TAG, "stopPreview");

      googleGlassXE10WorkAround(mCamera);

    } catch (Exception e) {
      // ignore: tried to stop a non-existent preview
      Log.d(TAG, "Tried to stop a non-existent preview: " + e.getMessage());
    }

    // start preview with new settings
    try {
      mCamera.setPreviewDisplay(mHolder);
      mCamera.startPreview();
      Log.v(TAG, "startPreview");

    } catch (Exception e) {
      Log.d(TAG, "Error starting camera preview: " + e.getMessage());
    }
  }
  public void startTranscode() {

    try {
      transcode();

    } catch (Exception e) {

      buttonStart.setEnabled(false);

      String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

      showMessageBox(
          message,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {}
          });
    }
  }
  protected void getFileInfo() {
    try {
      mediaFileInfo = new MediaFileInfo(new AndroidMediaObjectFactory(getApplicationContext()));
      mediaFileInfo.setUri(mediaUri1);

      duration = mediaFileInfo.getDurationInMicroSec();

      audioFormat = (AudioFormat) mediaFileInfo.getAudioFormat();
      if (audioFormat == null) {
        showMessageBox(
            "Audio format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }

      videoFormat = (VideoFormat) mediaFileInfo.getVideoFormat();
      if (videoFormat == null) {
        showMessageBox(
            "Video format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      } else {
        videoWidthIn = videoFormat.getVideoFrameSize().width();
        videoHeightIn = videoFormat.getVideoFrameSize().height();
      }
    } catch (Exception e) {
      String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

      showMessageBox(
          message,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {}
          });
    }
  }
  protected void displayVideoFrame(SurfaceHolder holder) {

    if (videoFormat != null) {
      try {
        ISurfaceWrapper surface = AndroidMediaObjectFactory.Converter.convert(holder.getSurface());
        mediaFileInfo.setOutputSurface(surface);

        ByteBuffer buffer = ByteBuffer.allocate(1);
        mediaFileInfo.getFrameAtPosition(100, buffer);

      } catch (Exception e) {
        String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

        showMessageBox(
            message,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }
    }
  }
Ejemplo n.º 5
0
  private String[] getCommandLine() {
    InputStream is;
    try {
      is = getAssets().open("_cl_");
      byte[] len = new byte[4];
      int r = is.read(len);
      if (r < 4) {
        Log.d("XXX", "**ERROR** Wrong cmdline length.\n");
        Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
        return new String[0];
      }
      int argc =
          ((int) (len[3] & 0xFF) << 24)
              | ((int) (len[2] & 0xFF) << 16)
              | ((int) (len[1] & 0xFF) << 8)
              | ((int) (len[0] & 0xFF));
      String[] cmdline = new String[argc];

      for (int i = 0; i < argc; i++) {
        r = is.read(len);
        if (r < 4) {

          Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
          return new String[0];
        }
        int strlen =
            ((int) (len[3] & 0xFF) << 24)
                | ((int) (len[2] & 0xFF) << 16)
                | ((int) (len[1] & 0xFF) << 8)
                | ((int) (len[0] & 0xFF));
        if (strlen > 65535) {
          Log.d("GODOT", "**ERROR** Wrong command len\n");
          return new String[0];
        }
        byte[] arg = new byte[strlen];
        r = is.read(arg);
        if (r == strlen) {
          cmdline[i] = new String(arg, "UTF-8");
        }
      }
      return cmdline;
    } catch (Exception e) {
      e.printStackTrace();
      Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
      return new String[0];
    }
  }
Ejemplo n.º 6
0
 // Called from native
 public byte[] openAssetFile(String name) {
   name = name.substring(8); // strip "/assets/" from name
   Log.i("ZgeAndroid", "About to open: " + name);
   AssetManager assets = getContext().getAssets();
   byte[] data = new byte[0]; // Return zero length to native if file not available
   try {
     InputStream stream = assets.open(name, AssetManager.ACCESS_BUFFER);
     int size = stream.available();
     Log.i("ZgeAndroid", "Open ok, available: " + size);
     data = new byte[size];
     stream.read(data);
     stream.close();
   } catch (Exception e) {
     Log.e("ZgeAndroid", e.getMessage());
   }
   return data;
 }
Ejemplo n.º 7
0
 public void reconnect5() {
   try {
     List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
     for (WifiConfiguration i : list) {
       if (i.SSID.equals(FirstSettings_two.first_ssid)) {
         wifiManager.enableNetwork(i.networkId, true);
         wifiManager.reconnect();
         File_Video downloadFile_video = new File_Video();
         downloadFile_video.execute(BroadcastNewSms.filepath);
         break;
       }
     }
   } catch (Exception e) {
     Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show();
   }
   ;
 }
Ejemplo n.º 8
0
        private void doRetryableAlert(Exception e, String msg) {
          AlertDialog.Builder dialog = new AlertDialog.Builder(SelectAccount.this);
          dialog.setTitle(msg);
          String dispMsg = msg + "\n\n" + e.getMessage();
          dialog.setMessage(dispMsg);
          dialog.setPositiveButton(
              "Retry",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  requestAccountList();
                }
              });
          dialog.setNegativeButton("Cancel", emptyClickListener);

          AlertDialog dlg = dialog.create();
          dlg.show();
        }
Ejemplo n.º 9
0
 @Override
 protected void onPostExecute(String result) {
   try {
     if (result.equals("Downloaded")) {
       Toast.makeText(getApplicationContext(), "Загрузка видео завершена", Toast.LENGTH_LONG)
           .show();
       play();
       Toast.makeText(getApplicationContext(), "отключение Wi-Fi", Toast.LENGTH_LONG).show();
       disconnect();
     } else {
       Toast.makeText(getApplicationContext(), "Ошибка с загрузкой видео", Toast.LENGTH_LONG)
           .show();
     }
   } catch (Exception e) {
     Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG)
         .show();
   }
 }
Ejemplo n.º 10
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.test:
       String rootdir = Environment.getRootDirectory().getAbsolutePath();
       String datadir = Environment.getDataDirectory().getAbsolutePath();
       String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();
       mEdit.setText(
           String.format(
               "ext = %s\nroot=%s\ndata=%s\ncache=%s", mSdPath, rootdir, datadir, cachedir));
       break;
     case R.id.save:
       File dir = new File(mSdPath + "/dir");
       dir.mkdir();
       File file = new File(mSdPath + "/dir/file.txt");
       try {
         FileOutputStream fos = new FileOutputStream(file);
         String str = "This file exists in SDcard";
         fos.write(str.getBytes());
         fos.close();
         mEdit.setText("write success");
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found." + e.getMessage());
       } catch (SecurityException e) {
         mEdit.setText("Security Exception");
       } catch (Exception e) {
         mEdit.setText(e.getMessage());
       }
       break;
     case R.id.load:
       try {
         FileInputStream fis = new FileInputStream(mSdPath + "/dir/file.txt");
         byte[] data = new byte[fis.available()];
         while (fis.read(data) != -1) {;
         }
         fis.close();
         mEdit.setText(new String(data));
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found");
       } catch (Exception e) {;
       }
       break;
   }
 }
Ejemplo n.º 11
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
Ejemplo n.º 12
0
 @Override
 public void surfaceCreated(SurfaceHolder holder) {
   if (mediaRecorder == null) {
     try {
       Log.d(TAG, "Opening camera");
       camera = Camera.open();
       Log.d(TAG, "Camera opened");
       Camera.Parameters parameters = camera.getParameters();
       setRequestedOrientation(90);
       camera.setDisplayOrientation(90);
       camera.setParameters(parameters);
       Log.d(TAG, "Set parameters");
       camera.setPreviewDisplay(holder); // set SurfaceHolder as destination for frames
       Log.d(TAG, "Set preview display");
       camera.startPreview();
       Button takePhotoButton = (Button) findViewById(R.id.takePhotoButton);
       takePhotoButton.setVisibility(View.VISIBLE);
       Log.d(TAG, "Button visible");
       Log.d(TAG, "Preview started");
     } catch (Exception e) {
       Log.d(TAG, e.getMessage());
     }
   }
 }
Ejemplo n.º 13
0
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.takePhotoButton) {
      camera.takePicture(shutterCallback, rawCallback, jpegCallback);
      Button takePhotoButton = (Button) findViewById(R.id.takePhotoButton);
      takePhotoButton.setVisibility(View.INVISIBLE);
    }
    if (v.getId() == R.id.cameraTryAgainButton) {
      Button saveButton = (Button) findViewById(R.id.savePhotoButton);
      saveButton.setVisibility(View.INVISIBLE);
      Button cameraTryAgainButton = (Button) findViewById(R.id.cameraTryAgainButton);
      cameraTryAgainButton.setVisibility(View.INVISIBLE);
      Button takePhotoButton = (Button) findViewById(R.id.takePhotoButton);
      takePhotoButton.setVisibility(View.VISIBLE);
      camera.startPreview();
      /*canvas = holder.lockCanvas();
      Picture picture = new Picture();
      picture.draw(canvas);
      canvas.drawPicture(picture);
      holder.unlockCanvasAndPost(canvas);*/
    }
    if (v.getId() == R.id.savePhotoButton) {
      filename = "picture" + ic.numberOfPictures + ".jpg"; // STEP ONE : Set filename
      ic.numberOfPictures++;
      file = path + filename;

      Calendar calendar = new GregorianCalendar(); // STEP TWO : Get Calendar object
      int month = calendar.get(calendar.MONTH); // 			  and time/date
      int day = calendar.get(calendar.DAY_OF_MONTH);
      String time = calendar.getTime().toString().substring(11, 19);
      int hour = Integer.valueOf(time.substring(0, 2));
      if (hour > 12) {
        int oldHour = hour; // STEP THREE: Format time
        hour = hour - 12;
        String oldS = Integer.toString(oldHour);
        String hourS = Integer.toString(hour);
        if (hourS.length() == 1) hourS = "0" + hourS;
        time = time.substring(2);
        time = hourS + time;
        time.replaceFirst(oldS, hourS);
        isAM = false;
      }
      if (isAM) time = time + " AM " + " ---		Picture";
      else time = time + " PM " + " ---		Picture";
      String year = new Integer(calendar.get(calendar.YEAR)).toString();
      database
          .get(year)
          .get(months[month])
          .get(days[day - 1])
          .put(time, file); // STEP FOUR: Pull day out of
      Toast.makeText(this, "Picture saved to: " + file, Toast.LENGTH_LONG)
          .show(); //			  the database
      Button saveButton = (Button) findViewById(R.id.savePhotoButton);
      saveButton.setVisibility(View.INVISIBLE);
      Button takePhotoButton = (Button) findViewById(R.id.takePhotoButton);
      takePhotoButton.setVisibility(View.INVISIBLE);
      try {
        FileOutputStream camFOS =
            new FileOutputStream(file); // STEP FIVE: Save picture to MindBook directory
        camFOS.write(picture);
        camFOS.close();
      } catch (FileNotFoundException fnfe) {
        Log.d("CAMERA", fnfe.getMessage());
      } catch (IOException ioe) {
        Log.d("CAMERA", ioe.getMessage());
      }
      try {
        ObjectOutputStream dataOOS =
            new ObjectOutputStream(new FileOutputStream(path + "database.ser"));
        dataOOS.writeObject(database);
        dataOOS.close();
        ObjectOutputStream counterOOS =
            new ObjectOutputStream(new FileOutputStream(path + "counter.ser"));
        counterOOS.writeObject(ic);
        counterOOS.close();
      } catch (Exception e) {
        Log.d("CAMERA", e.getMessage());
      }
    }
  }
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
      throws JSONException {
    PluginResult pr =
        new PluginResult(PluginResult.Status.ERROR, "Unhandled execute call: " + action);

    if (action.equals("openDevice")) {
      if (mMTSCRA == null) {
        InitializeDevice();
      }

      if (mbAudioConnected) {
        if (mMTSCRA.getDeviceType() == MagTekSCRA.DEVICE_TYPE_AUDIO) {
          // Thread tSetupAudioParams = new Thread() {
          //	public void run() {
          try {
            mStringAudioConfigResult = setupAudioParameters();
          } catch (Exception ex) {
            mStringAudioConfigResult = "Error:" + ex.getMessage();
          }
          //	}
          // }

          // tSetupAudioParams.start();
        } else {
        }
        mMTSCRA.openDevice();

        pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected());
      } else {
        pr = new PluginResult(PluginResult.Status.ERROR, "No reader attached.");
      }
    } else if (action.equals("closeDevice")) {
      mMTSCRA.closeDevice();

      pr = new PluginResult(PluginResult.Status.OK, !mMTSCRA.isDeviceConnected());
    } else if (action.equals("isDeviceConnected")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected());
    } else if (action.equals("isDeviceOpened")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.isDeviceConnected());
    } else if (action.equals("clearCardData")) {
      pr = new PluginResult(PluginResult.Status.OK);
    }
    /*		else if(action.equals("setCardData")) {
    			try {
    				;
    			}
    		}
    		else if(action.equals("getTrackDecodeStatus")) {
    			try {
    				;
    			}
    		}
    */
    else if (action.equals("getTrack1")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack1());
    } else if (action.equals("getTrack2")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack2());
    } else if (action.equals("getTrack3")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack3());
    } else if (action.equals("getTrack1Masked")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack1Masked());
    } else if (action.equals("getTrack2Masked")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack2Masked());
    } else if (action.equals("getTrack3Masked")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getTrack3Masked());
    } else if (action.equals("getMagnePrintStatus")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getMagnePrintStatus());
    } else if (action.equals("getMagnePrint")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getMagnePrint());
    } else if (action.equals("getDeviceSerial")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getDeviceSerial());
    } else if (action.equals("getSessionID")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getSessionID());
    }
    /*		else if(action.equals("setDeviceProtocolString")) {
    			try {
    				;
    			}
    		}
    */
    else if (action.equals("listenForEvents")) {
      pr = new PluginResult(PluginResult.Status.NO_RESULT);
      pr.setKeepCallback(true);

      mEventListenerCb = callbackContext;
    } else if (action.equals("getCardName")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardName());
    } else if (action.equals("getCardIIN")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardIIN());
    } else if (action.equals("getCardLast4")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardLast4());
    } else if (action.equals("getCardExpDate")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardExpDate());
    } else if (action.equals("getCardServiceCode")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardServiceCode());
    } else if (action.equals("getCardStatus")) {
      pr = new PluginResult(PluginResult.Status.OK, mMTSCRA.getCardStatus());
    }
    /*
    		else if(action.equals("setDeviceType")) {
    			try {
    				;
    			}
    		}
    */
    else if (action.equals("setDeviceType")) {;
    }

    callbackContext.sendPluginResult(pr);

    return true;
  }
Ejemplo n.º 15
0
  /**
   * Given a location fix, processes it and displays it in the table on the form.
   *
   * @param loc Location information
   */
  private void DisplayLocationInfo(Location loc) {
    Utilities.LogDebug("GpsMainActivity.DisplayLocationInfo");
    try {

      if (loc == null) {
        return;
      }

      TextView tvLatitude = (TextView) findViewById(R.id.txtLatitude);
      TextView tvLongitude = (TextView) findViewById(R.id.txtLongitude);
      TextView tvDateTime = (TextView) findViewById(R.id.txtDateTimeAndProvider);

      TextView tvAltitude = (TextView) findViewById(R.id.txtAltitude);

      TextView txtSpeed = (TextView) findViewById(R.id.txtSpeed);

      TextView txtSatellites = (TextView) findViewById(R.id.txtSatellites);
      TextView txtDirection = (TextView) findViewById(R.id.txtDirection);
      TextView txtAccuracy = (TextView) findViewById(R.id.txtAccuracy);
      String providerName = loc.getProvider();

      if (providerName.equalsIgnoreCase("gps")) {
        providerName = getString(R.string.providername_gps);
      } else {
        providerName = getString(R.string.providername_celltower);
      }

      tvDateTime.setText(
          new Date(Session.getLatestTimeStamp()).toLocaleString()
              + getString(R.string.providername_using, providerName));
      tvLatitude.setText(String.valueOf(loc.getLatitude()));
      tvLongitude.setText(String.valueOf(loc.getLongitude()));

      if (loc.hasAltitude()) {

        double altitude = loc.getAltitude();

        if (AppSettings.shouldUseImperial()) {
          tvAltitude.setText(
              String.valueOf(Utilities.MetersToFeet(altitude)) + getString(R.string.feet));
        } else {
          tvAltitude.setText(String.valueOf(altitude) + getString(R.string.meters));
        }

      } else {
        tvAltitude.setText(R.string.not_applicable);
      }

      if (loc.hasSpeed()) {

        float speed = loc.getSpeed();
        String unit;
        if (AppSettings.shouldUseImperial()) {
          if (speed > 1.47) {
            speed = speed * 0.6818f;
            unit = getString(R.string.miles_per_hour);

          } else {
            speed = Utilities.MetersToFeet(speed);
            unit = getString(R.string.feet_per_second);
          }
        } else {
          if (speed > 0.277) {
            speed = speed * 3.6f;
            unit = getString(R.string.kilometers_per_hour);
          } else {
            unit = getString(R.string.meters_per_second);
          }
        }

        txtSpeed.setText(String.valueOf(speed) + unit);

      } else {
        txtSpeed.setText(R.string.not_applicable);
      }

      if (loc.hasBearing()) {

        float bearingDegrees = loc.getBearing();
        String direction;

        direction = Utilities.GetBearingDescription(bearingDegrees, getApplicationContext());

        txtDirection.setText(
            direction
                + "("
                + String.valueOf(Math.round(bearingDegrees))
                + getString(R.string.degree_symbol)
                + ")");
      } else {
        txtDirection.setText(R.string.not_applicable);
      }

      if (!Session.isUsingGps()) {
        txtSatellites.setText(R.string.not_applicable);
        Session.setSatelliteCount(0);
      }

      if (loc.hasAccuracy()) {

        float accuracy = loc.getAccuracy();

        if (AppSettings.shouldUseImperial()) {
          txtAccuracy.setText(
              getString(
                  R.string.accuracy_within,
                  String.valueOf(Utilities.MetersToFeet(accuracy)),
                  getString(R.string.feet)));

        } else {
          txtAccuracy.setText(
              getString(
                  R.string.accuracy_within, String.valueOf(accuracy), getString(R.string.meters)));
        }

      } else {
        txtAccuracy.setText(R.string.not_applicable);
      }

    } catch (Exception ex) {
      SetStatus(getString(R.string.error_displaying, ex.getMessage()));
    }
  }
Ejemplo n.º 16
0
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v("SDL", "Device: " + android.os.Build.DEVICE);
    Log.v("SDL", "Model: " + android.os.Build.MODEL);
    Log.v("SDL", "onCreate():" + mSingleton);
    super.onCreate(savedInstanceState);

    SDLActivity.initialize();
    // So we can call stuff from static callbacks
    mSingleton = this;

    // Load shared libraries
    String errorMsgBrokenLib = "";
    try {
      loadLibraries();
    } catch (UnsatisfiedLinkError e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    } catch (Exception e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    }

    if (mBrokenLibraries) {
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(
          "An error occurred while trying to start the application. Please try again and/or reinstall."
              + System.getProperty("line.separator")
              + System.getProperty("line.separator")
              + "Error: "
              + errorMsgBrokenLib);
      dlgAlert.setTitle("SDL Error");
      dlgAlert.setPositiveButton(
          "Exit",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
              // if this button is clicked, close current activity
              SDLActivity.mSingleton.finish();
            }
          });
      dlgAlert.setCancelable(false);
      dlgAlert.create().show();

      return;
    }

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    if (Build.VERSION.SDK_INT >= 12) {
      mJoystickHandler = new SDLJoystickHandler_API12();
    } else {
      mJoystickHandler = new SDLJoystickHandler();
    }

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
Ejemplo n.º 17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // new
    getActionBar().hide(); // new
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
    first_activity_bool = true;
    Window window = this.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    first_activity = this;
    context = getApplicationContext();
    ConnectivityManager connMgr =
        (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
    android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    try {
      if ((wifi.isConnected() == false)) {
        Toast.makeText(getApplicationContext(), "подключение к сети Wi-Fi", Toast.LENGTH_LONG)
            .show();
        reconnect5();
      } else {
        //  Toast.makeText(getApplicationContext(), "Уже соеденено", Toast.LENGTH_LONG).show();
        File_Video downloadFile_video = new File_Video();
        downloadFile_video.execute(BroadcastNewSms.filepath);
      }

    } catch (Exception e) {
      Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show();
    }

    mPreview = (SurfaceView) findViewById(R.id.video_surface);
    holder = mPreview.getHolder();
    holder.addCallback(BroadcastNewSms_Two.this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    mp = new MediaPlayer();

    decorView = findViewById(R.id.firstsettings_two_layout);

    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    decorView.setSystemUiVisibility(uiOptions);
    View decorView2 = getWindow().getDecorView();
    decorView2.setOnSystemUiVisibilityChangeListener(
        new View.OnSystemUiVisibilityChangeListener() {
          @Override
          public void onSystemUiVisibilityChange(int visibility) {
            // Note that system bars will only be "visible" if none of the
            // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
            if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {

              timer1();

            } else {

            }
          }
        });

    timer2();
  }