Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibratorActive = v.hasVibrator();

    // Setting up File Selection handlers and callbacks
    final PlutoboyActivity pba = this;
    final FileSelectedListener fl =
        new FileSelectedListener() {
          public void onFileSelected(File file) {
            lock.lock();
            try {
              fileSelectedPath = file.getAbsolutePath();
              fileSelectedB = true;
              fileSelected.signal();
            } finally {
              lock.unlock();
            }
          }
        };

    fileDialogHandler =
        new Handler() {
          public void handleMessage(Message msg) {
            SimpleFileChooser fc =
                new SimpleFileChooser(pba, Environment.getExternalStorageDirectory(), fl);
            fc.showDialog();
          }
        };
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "My oncreate running");
    resourceManager = new ResourceManager(this);
    this.showLoadingScreen();
    File app_root_file = new File(getAppRoot());

    Log.v(TAG, "Ready to unpack");
    unpackData("private", app_root_file);

    Log.v(TAG, "About to do super onCreate");
    super.onCreate(savedInstanceState);
    Log.v(TAG, "Did super onCreate");

    this.mActivity = this;
    this.showLoadingScreen();

    String app_root_dir = getAppRoot();
    String mFilesDirectory = mActivity.getFilesDir().getAbsolutePath();
    Log.v(TAG, "Setting env vars for start.c and Python to use");
    SDLActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);
    SDLActivity.nativeSetEnv("ANDROID_ARGUMENT", app_root_dir);
    SDLActivity.nativeSetEnv("ANDROID_APP_PATH", app_root_dir);
    SDLActivity.nativeSetEnv("ANDROID_ENTRYPOINT", "main.pyo");
    SDLActivity.nativeSetEnv("PYTHONHOME", app_root_dir);
    SDLActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib");

    try {
      Log.v(TAG, "Access to our meta-data...");
      this.mMetaData =
          this.mActivity
              .getPackageManager()
              .getApplicationInfo(this.mActivity.getPackageName(), PackageManager.GET_META_DATA)
              .metaData;

      PowerManager pm = (PowerManager) this.mActivity.getSystemService(Context.POWER_SERVICE);
      if (this.mMetaData.getInt("wakelock") == 1) {
        this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
      }
      if (this.mMetaData.getInt("surface.transparent") != 0) {
        Log.v(TAG, "Surface will be transparent.");
        getSurface().setZOrderOnTop(true);
        getSurface().getHolder().setFormat(PixelFormat.TRANSPARENT);
      } else {
        Log.i(TAG, "Surface will NOT be transparent");
      }
    } catch (PackageManager.NameNotFoundException e) {
    }
  }