Exemplo n.º 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    mAppContext = this;
    mMainHandler = new Handler();

    if (!sTryCatchAttached) {
      sTryCatchAttached = true;
      mMainHandler.post(
          new Runnable() {
            public void run() {
              try {
                Looper.loop();
              } catch (Exception e) {
                Log.e(LOG_FILE_NAME, "top level exception", e);
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);
                pw.flush();
                GeckoAppShell.reportJavaCrash(sw.toString());
              }
              // resetting this is kinda pointless, but oh well
              sTryCatchAttached = false;
            }
          });
    }

    SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
    String localeCode = settings.getString(getPackageName() + ".locale", "");
    if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode);

    Log.i(LOG_FILE_NAME, "create");
    super.onCreate(savedInstanceState);

    if (sGREDir == null) sGREDir = new File(this.getApplicationInfo().dataDir);

    getWindow()
        .setFlags(
            mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (cameraView == null) {
      cameraView = new SurfaceView(this);
      cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    if (surfaceView == null) surfaceView = new GeckoSurfaceView(this);
    else mainLayout.removeAllViews();

    mainLayout = new AbsoluteLayout(this);
    mainLayout.addView(
        surfaceView,
        new AbsoluteLayout.LayoutParams(
            AbsoluteLayout.LayoutParams.MATCH_PARENT, // level 8
            AbsoluteLayout.LayoutParams.MATCH_PARENT,
            0,
            0));

    setContentView(
        mainLayout,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mConnectivityFilter = new IntentFilter();
    mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mConnectivityReceiver = new GeckoConnectivityReceiver();

    IntentFilter batteryFilter = new IntentFilter();
    batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    mBatteryReceiver = new GeckoBatteryManager();
    registerReceiver(mBatteryReceiver, batteryFilter);

    if (SmsManager.getInstance() != null) {
      SmsManager.getInstance().start();
    }

    GeckoNetworkManager.getInstance().init();

    if (!checkAndSetLaunchState(LaunchState.PreLaunch, LaunchState.Launching)) return;

    checkAndLaunchUpdate();
    mLibLoadThread =
        new Thread(
            new Runnable() {
              public void run() {
                // At some point while loading the gecko libs our default locale gets set
                // so just save it to locale here and reset it as default after the join
                Locale locale = Locale.getDefault();
                GeckoAppShell.loadGeckoLibs(getApplication().getPackageResourcePath());
                Locale.setDefault(locale);
                Resources res = getBaseContext().getResources();
                Configuration config = res.getConfiguration();
                config.locale = locale;
                res.updateConfiguration(config, res.getDisplayMetrics());
              }
            });
    mLibLoadThread.start();
  }
Exemplo n.º 2
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();
  }