Example #1
0
 // Load the .so
 static {
   System.loadLibrary("SDL");
   // System.loadLibrary("SDL_image");
   // System.loadLibrary("SDL_mixer");
   // System.loadLibrary("SDL_ttf");
   System.loadLibrary("main");
 }
Example #2
0
 // Load the .so
 static {
   System.loadLibrary("SDL2");
   System.loadLibrary("SDL2_image");
   // System.loadLibrary("SDL2_mixer");
   // System.loadLibrary("SDL2_net");
   System.loadLibrary("SDL2_ttf");
   System.loadLibrary("main");
 }
  public void onDestroy() {
    running = false;
    if (scanThread != null) scanThread.interrupt();

    if (myWLocate != null) myWLocate.doPause();

    sensorManager.unregisterListener(
        this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER));

    if (scanData.getmView() != null) {
      ((WindowManager) getSystemService(WINDOW_SERVICE)).removeView(scanData.getmView());
      scanData.setmView(null);
    }
    try {
      if (wl != null) wl.release();
    } catch (RuntimeException re) {
    }
    wl = null;
    try {
      scanThread.join(1000);
    } catch (InterruptedException ie) {

    }
    System.exit(0);
  }
Example #4
0
  /**
   * Call this when data is loaded. The UI will perform complete at once or after a delay, depends
   * on the time elapsed is greater then {@link #mLoadingMinTime} or not.
   */
  public final void refreshComplete() {
    if (DEBUG) {
      PtrCLog.i(LOG_TAG, "refreshComplete");
    }

    if (mRefreshCompleteHook != null) {
      mRefreshCompleteHook.reset();
    }

    int delay = (int) (mLoadingMinTime - (System.currentTimeMillis() - mLoadingStartTime));
    if (delay <= 0) {
      if (DEBUG) {
        PtrCLog.d(LOG_TAG, "performRefreshComplete at once");
      }
      performRefreshComplete();
    } else {
      postDelayed(
          new Runnable() {
            @Override
            public void run() {
              performRefreshComplete();
            }
          },
          delay);
      if (DEBUG) {
        PtrCLog.d(LOG_TAG, "performRefreshComplete after delay: %s", delay);
      }
    }
  }
Example #5
0
  public Zge(Context context) {
    super(context);

    System.loadLibrary("zgeandroid");

    String dataPath = context.getFilesDir().getAbsolutePath() + "/";
    String libraryPath = getContext().getApplicationInfo().dataDir + "/lib/";
    String extPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    NativeInit(extPath, dataPath, libraryPath);

    initZApp();

    // The lines below are needed to get alpha channel
    // Source: https://github.com/Wizcorp/Ejecta-X/issues/13
    setZOrderOnTop(true);
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    getHolder().setFormat(android.graphics.PixelFormat.RGBA_8888);

    if (NativeGetGLBase() == 1) {
      Log.i("ZgeAndroid", "GLES 2");
      setEGLContextClientVersion(2);
    }
    Renderer = new CRenderer();
    setRenderer(Renderer);

    setFocusableInTouchMode(true);
  }
Example #6
0
  /** 刷新本地全局搜索粉丝 */
  private void refreshLocalFans() {
    long last_refresh_all_fans_time =
        PreferenceUtils.getLong(context, Constant.LAST_REFRESH_ALLFANS_TIME, 0);
    long currentTime = System.currentTimeMillis();

    if (currentTime - last_refresh_all_fans_time > THREE_HOUR) {

      int empID = PreferenceUtils.getInt(context, Constant.PREFERENCE_EMP_ID, 0);
      HttpRequestController.fansGroup(
          context,
          empID,
          5,
          1000,
          1,
          1,
          1,
          new HttpResponseListener<ApiFansGroup.ApiFansGroupResponse>() {
            @Override
            public void onResult(ApiFansGroup.ApiFansGroupResponse response) {
              if (response.getRetCode() == BaseResponse.RET_HTTP_STATUS_OK) {
                List<Fans> fans = response.fansGroupResult.fans;
                MyLogger.i(TAG, "fans: " + fans.size());

                ApiAllFansInfoDb.delete(context);
                ApiAllFansInfoDb.bulkInsert(context, fans);
                PreferenceUtils.putLong(
                    context, Constant.LAST_REFRESH_ALLFANS_TIME, System.currentTimeMillis());
              }
              // Utils.toast(context, "" + response.getRetInfo());
            }
          });
    }
  }
  /** Notify user when they have a score that's a multiple of ten. */
  private void generateScoreNotification() {
    int suc = Score.getSuccesses();
    int mod = suc % 10;

    if (suc < 0 || mod != 0) return;

    String title = "MathApp Score";
    String text = "MathApp score reached " + suc + " points!";

    Intent onTrigger = new Intent(this, ActivityScore.class);
    PendingIntent pending =
        PendingIntent.getActivity(this, 0, onTrigger, Intent.FLAG_ACTIVITY_NEW_TASK);

    int nResID = R.drawable.ic_launcher;
    String nText = title;
    long nTime = System.currentTimeMillis();

    Notification notification = new Notification(nResID, nText, nTime);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.setLatestEventInfo(this, title, text, pending);

    NotificationManager manager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
  }
Example #8
0
    @Override
    public void onScroll(
        AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
      if (loading) {
        if (totalItemCount > previousTotal) {
          loading = false;
          previousTotal = totalItemCount;
          currentPage++;
        }
      }

      if (!loading
          && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
        tcallbacks.LoadDataForScroll(totalItemCount);
        loading = true;
      }

      if (previousFirstVisibleItem != firstVisibleItem) {
        currTime = System.currentTimeMillis();
        timeToScrollOneElement = currTime - previousEventTime;
        speed = ((double) 1 / timeToScrollOneElement) * 1000;

        previousFirstVisibleItem = firstVisibleItem;
        previousEventTime = currTime;
      }
    }
  /**
   * Saves the image on the SD card and inserts a record into the DB.
   *
   * @param lastPic the image to save
   * @return the filename of the saved image
   */
  public String saveImage(byte[] lastPic) {
    final String imageFileName = String.valueOf(System.currentTimeMillis()) + ".jpg";

    File root = Environment.getExternalStorageDirectory();

    // create the note folder if it doesn't exist
    File folder = new File(root, Note.FOLDER_PREFIX);
    if (!folder.isDirectory()) folder.mkdir();

    // decode the image into a Bitmap
    Bitmap bmp = BitmapFactory.decodeByteArray(lastPic, 0, lastPic.length);

    File targetFile = new File(folder, imageFileName);
    FileOutputStream out = null;
    try {
      out = new FileOutputStream(targetFile);
      if (!bmp.compress(Bitmap.CompressFormat.JPEG, 90, out))
        throw new IOException("Error writing bmp to stream!");
      db.addNewImage(imageFileName);
    } catch (IOException e) {
      Log.e(SBActivity.TAG, "Error writing image file", e);
    } finally {
      try {
        out.close();
      } catch (Exception e) {
        // ignore
      }
    }

    return imageFileName;
  }
  private void setState(State state) {
    this.state = state;
    switch (state) {
      case PULL_TO_REFRESH:
        spinner.setVisibility(View.INVISIBLE);
        image.setVisibility(View.VISIBLE);
        text.setText(pullToRefreshText);

        if (showLastUpdatedText && lastUpdated != -1) {
          lastUpdatedTextView.setVisibility(View.VISIBLE);
          lastUpdatedTextView.setText(
              String.format(lastUpdatedText, lastUpdatedDateFormat.format(new Date(lastUpdated))));
        }

        break;

      case RELEASE_TO_REFRESH:
        spinner.setVisibility(View.INVISIBLE);
        image.setVisibility(View.VISIBLE);
        text.setText(releaseToRefreshText);
        break;

      case REFRESHING:
        setUiRefreshing();

        lastUpdated = System.currentTimeMillis();
        if (onRefreshListener == null) {
          setState(State.PULL_TO_REFRESH);
        } else {
          onRefreshListener.onRefresh();
        }

        break;
    }
  }
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (item.getItemId() == R.id.add_item) {
      GroupClass newGroup = new GroupClass("New Group " + System.currentTimeMillis());
      newGroup.addChild(new ChildClass("New Child", "Child Text: " + System.currentTimeMillis()));
      this.groups.add(0, newGroup);

      this.adapter.notifyDataSetChanged();

      return true;
    } else if (item.getItemId() == R.id.remove_item) {
      this.groups.remove(0);

      this.adapter.notifyDataSetChanged();

      return true;
    } else {
      return super.onMenuItemSelected(featureId, item);
    }
  }
Example #12
0
 public void addEnvToIntent(Intent intent) {
   Map<String, String> envMap = System.getenv();
   Set<Map.Entry<String, String>> envSet = envMap.entrySet();
   Iterator<Map.Entry<String, String>> envIter = envSet.iterator();
   int c = 0;
   while (envIter.hasNext()) {
     Map.Entry<String, String> entry = envIter.next();
     intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue());
     c++;
   }
 }
Example #13
0
  private void checkAndLaunchUpdate() {
    Log.i(LOG_FILE_NAME, "Checking for an update");

    int statusCode = 8; // UNEXPECTED_ERROR
    File baseUpdateDir = null;
    if (Build.VERSION.SDK_INT >= 8)
      baseUpdateDir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
    else baseUpdateDir = new File(Environment.getExternalStorageDirectory().getPath(), "download");

    File updateDir = new File(new File(baseUpdateDir, "updates"), "0");

    File updateFile = new File(updateDir, "update.apk");
    File statusFile = new File(updateDir, "update.status");

    if (!statusFile.exists() || !readUpdateStatus(statusFile).equals("pending")) return;

    if (!updateFile.exists()) return;

    Log.i(LOG_FILE_NAME, "Update is available!");

    // Launch APK
    File updateFileToRun = new File(updateDir, getPackageName() + "-update.apk");
    try {
      if (updateFile.renameTo(updateFileToRun)) {
        String amCmd =
            "/system/bin/am start -a android.intent.action.VIEW "
                + "-n com.android.packageinstaller/.PackageInstallerActivity -d file://"
                + updateFileToRun.getPath();
        Log.i(LOG_FILE_NAME, amCmd);
        Runtime.getRuntime().exec(amCmd);
        statusCode = 0; // OK
      } else {
        Log.i(LOG_FILE_NAME, "Cannot rename the update file!");
        statusCode = 7; // WRITE_ERROR
      }
    } catch (Exception e) {
      Log.i(LOG_FILE_NAME, "error launching installer to update", e);
    }

    // Update the status file
    String status = statusCode == 0 ? "succeeded\n" : "failed: " + statusCode + "\n";

    OutputStream outStream;
    try {
      byte[] buf = status.getBytes("UTF-8");
      outStream = new FileOutputStream(statusFile);
      outStream.write(buf, 0, buf.length);
      outStream.close();
    } catch (Exception e) {
      Log.i(LOG_FILE_NAME, "error writing status file", e);
    }

    if (statusCode == 0) System.exit(0);
  }
Example #14
0
 private void performRefresh() {
   mLoadingStartTime = System.currentTimeMillis();
   if (mPtrUIHandlerHolder.hasHandler()) {
     mPtrUIHandlerHolder.onUIRefreshBegin(this);
     if (DEBUG) {
       PtrCLog.i(LOG_TAG, "PtrUIHandler: onUIRefreshBegin");
     }
   }
   if (mPtrHandler != null) {
     mPtrHandler.onRefreshBegin(this);
   }
 }
  private void saveData(TelemetryData data) {
    PrintWriter out;
    boolean newFile = false;

    if (saveCnt > 25000) {
      File logFile;
      int i;

      logFile = new File(telemetryDir + 99 + ".log");
      logFile.delete();
      newFile = true;

      for (i = 99; i > 0; i--) {
        logFile = new File(telemetryDir + (i - 1) + ".log");
        logFile.renameTo(new File(telemetryDir + i + ".log"));
      }
      saveCnt = 0;
    }

    try {
      String text = "";
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);

      saveCnt++;
      out = new PrintWriter(new FileOutputStream(telemetryDir + "0.log", true));
      if (newFile) {
        text =
            "Time\tLatitude\tLongitude\tSpeed\tAcceleration X\tAcceleration Y\tAcceleration Z\tCoG\tOrientation Y\tOrientation Z\n\n";
        out.print(text);
      }
      text = dateFormat.format(new Date(System.currentTimeMillis())) + "\t";
      if (posValid) text = text + lastLat + "\t" + lastLon + "\t" + m_lastSpeed + "\t";
      else text = text + "-\t-\t-\t";
      text =
          text
              + data.getAccelX()
              + "\t"
              + data.getAccelY()
              + "\t"
              + data.getAccelZ()
              + "\t"
              + data.CoG
              + "\t"
              + data.getOrientY()
              + "\t"
              + data.getOrientZ()
              + "\n\n";
      out.print(text);
      out.close();
    } catch (IOException ioe) {
    }
  }
  public void onSensorChanged(SensorEvent event) {
    synchronized (this) {
      switch (event.sensor.getType()) {
        case Sensor.TYPE_ACCELEROMETER:
          scanData.getTelemetryData().addAccel(event.values[0], event.values[1], event.values[2]);
          break;
        case Sensor.TYPE_ORIENTATION:
          scanData.getTelemetryData().addOrient(event.values[0], event.values[1], event.values[2]);
          break;
      }
      if (lastTelemetryTime == 0) lastTelemetryTime = System.currentTimeMillis();
      else if (System.currentTimeMillis() - lastTelemetryTime > 750) {
        TelemetryData submitData = new TelemetryData();

        submitData.set(scanData.getTelemetryData());
        if (scanData.isStoreTele()) saveData(submitData);
        scanData.getTelemetryData().reset();
        OWMapAtAndroid.sendMessage(OWMapAtAndroid.ScannerHandler.MSG_TELEMETRY, 0, 0, submitData);
        lastTelemetryTime = System.currentTimeMillis();
      }
    }
  }
Example #17
0
 @Override
 public boolean onKeyUp(int keyCode, KeyEvent event) {
   if (myKeyUnderTracking != -1) {
     if (myKeyUnderTracking == keyCode) {
       final boolean longPress =
           System.currentTimeMillis()
               > myTrackingStartTime + ViewConfiguration.getLongPressTimeout();
       ZLApplication.Instance().runActionByKey(keyCode, longPress);
     }
     myKeyUnderTracking = -1;
     return true;
   } else {
     final ZLKeyBindings bindings = ZLApplication.Instance().keyBindings();
     return bindings.hasBinding(keyCode, false) || bindings.hasBinding(keyCode, true);
   }
 }
Example #18
0
  @Override
  protected void onDestroy() {
    Log.e("SDL", "onDestroy()");
    if (toastShot != null) toastShot.cancel();

    if (player != null) player.onDestroy();

    stopProgressTask();
    System.gc();

    if (multicastLock != null) {
      multicastLock.release();
      multicastLock = null;
    }
    super.onDestroy();
  }
 public int selectStatusIconIndex(MtvReservation mtvreservation)
 {
     Log.d("smali", "Lcom/samsung/sec/mtv/ui/channelguide/MtvUiFragReservationList$ReservationAdapter;->selectStatusIconIndex(Lcom/samsung/sec/mtv/provider/MtvReservation;)I");
     int i;
     if(mtvreservation.mPgmStatus == 0 && mtvreservation.mTimeStart < System.currentTimeMillis() - 5000L)
     {
         MtvUtilDebug.Mid(Log.d(), "selectStatusIconIndex() : ooops!!! hit an expired reservation,setting it failed");
         i = 1;
         MtvReservationManager.UpdateStatus(getActivity(), mtvreservation, 2);
     } else
     if(mtvreservation.mPgmStatus == 0 || mtvreservation.mPgmStatus == 6 || mtvreservation.mPgmStatus == 1)
         i = 0;
     else
         i = 1;
     return i;
 }
 @Override
 protected void onPreExecute() {
   isrun = true;
   tip = 2;
   progressDialog =
       ProgressDialog.show(
           context, getString(R.string.optim_db_title), getString(R.string.wait));
   mPreferences.edit().putLong(PREF_OPTIM_DB, System.currentTimeMillis()).commit();
   Helpers.get_assetsBinary("sqlite3", context);
   Helpers.get_assetsScript(
       "sql_optimize", context, "busybox chmod 750 " + context.getFilesDir() + "/sqlite3", "");
   if (Helpers.isSystemApp(getActivity())) {
     new CMDProcessor()
         .sh.runWaitFor("busybox chmod 750 " + context.getFilesDir() + "/sql_optimize");
   } else {
     new CMDProcessor()
         .su.runWaitFor("busybox chmod 750 " + context.getFilesDir() + "/sql_optimize");
   }
 }
Example #21
0
 private void exitByDoubleClick() {
   try {
     long cTime = System.currentTimeMillis();
     if (cTime - lastBackClickTime > 2000) {
       if (toast != null) {
         toast.cancel();
       }
       lastBackClickTime = cTime;
       (toast = Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT)).show();
     } else {
       if (toast != null) {
         toast.cancel();
       }
       exit();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #22
0
  @Override
  protected void onNewIntent(Intent intent) {
    if (checkLaunchState(LaunchState.GeckoExiting)) {
      // We're exiting and shouldn't try to do anything else just incase
      // we're hung for some reason we'll force the process to exit
      System.exit(0);
      return;
    }
    final String action = intent.getAction();
    if (ACTION_DEBUG.equals(action)
        && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {

      mMainHandler.postDelayed(
          new Runnable() {
            public void run() {
              Log.i(LOG_FILE_NAME, "Launching from debug intent after 5s wait");
              setLaunchState(LaunchState.Launching);
              launch(null);
            }
          },
          1000 * 5 /* 5 seconds */);
      Log.i(LOG_FILE_NAME, "Intent : ACTION_DEBUG - waiting 5s before launching");
      return;
    }
    if (checkLaunchState(LaunchState.WaitForDebugger) || launch(intent)) return;

    if (Intent.ACTION_MAIN.equals(action)) {
      Log.i(LOG_FILE_NAME, "Intent : ACTION_MAIN");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
    } else if (Intent.ACTION_VIEW.equals(action)) {
      String uri = intent.getDataString();
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "onNewIntent: " + uri);
    } else if (ACTION_WEBAPP.equals(action)) {
      String uri = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
      Log.i(LOG_FILE_NAME, "Intent : WEBAPP - " + uri);
    } else if (ACTION_BOOKMARK.equals(action)) {
      String args = intent.getStringExtra("args");
      GeckoAppShell.sendEventToGecko(new GeckoEvent(args));
      Log.i(LOG_FILE_NAME, "Intent : BOOKMARK - " + args);
    }
  }
 protected void wloc_return_position(
     int ret, double lat, double lon, float radius, short ccode) {
   posValid = false;
   if (ret == WLocate.WLOC_OK) {
     lastGPSTime = System.currentTimeMillis();
     if (radius < OWMapAtAndroid.MAX_RADIUS) {
       if (GeoUtils.latlon2dist(lat, lon, lastLat, lastLon) < 10) {
         posValid =
             true; // use the position only when there is no too big jump in distance- elsewhere
                   // it could be a GPS bug
         ScanService.getScanData().setLatLon(lastLat, lastLon);
       }
       lastLat = lat;
       lastLon = lon;
     }
     lastRadius = radius;
   } else {
     lastRadius = -1;
   }
   posState = 2;
   scanThread.interrupt();
 }
Example #24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    articleFeed = new ArticleFeed(this.getBaseContext());
    setFeed(articleFeed);

    articleFeed.loadCache();

    ThumbnailCache.getInstance().setContext(getBaseContext());

    setContentView(R.layout.articles_list);
    rubricsList = (LinearLayout) findViewById(R.id.articles_list);
    emptyMessage = (TextView) findViewById(R.id.empty);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String fontSize = preferences.getString("font_list_size", "medium");

    float imageSize = 12;
    if (fontSize.equalsIgnoreCase("small")) {
      imageSize = getResources().getDimension(R.dimen.image_size_small);
    } else if (fontSize.equalsIgnoreCase("medium")) {
      imageSize = getResources().getDimension(R.dimen.image_size_medium);
    } else if (fontSize.equalsIgnoreCase("large")) {
      imageSize = getResources().getDimension(R.dimen.image_size_large);
    }

    Display display =
        ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth();

    int maxImageCount = (int) (width / imageSize + 1);
    Rubric.setDefaultViewCount(maxImageCount);
    System.gc();

    listArticlesViews = new LinkedList<View>();
    generateRubricsList();
  }
Example #25
0
  public synchronized void update(int progress) {
    if (foreground) {
      browserController.updateProgress(progress);
    }

    setAlbumCover(ViewUnit.capture(this, dimen144dp, dimen108dp, false, Bitmap.Config.RGB_565));
    if (isLoadFinish()) {
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
      if (sp.getBoolean(context.getString(R.string.sp_scroll_bar), true)) {
        setHorizontalScrollBarEnabled(true);
        setVerticalScrollBarEnabled(true);
      } else {
        setHorizontalScrollBarEnabled(false);
        setVerticalScrollBarEnabled(false);
      }
      setScrollbarFadingEnabled(true);

      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  setAlbumCover(
                      ViewUnit.capture(
                          NinjaWebView.this, dimen144dp, dimen108dp, false, Bitmap.Config.RGB_565));
                }
              },
              animTime);

      if (prepareRecord()) {
        RecordAction action = new RecordAction(context);
        action.open(true);
        action.addHistory(new Record(getTitle(), getUrl(), System.currentTimeMillis()));
        action.close();
        browserController.updateAutoComplete();
      }
    }
  }
Example #26
0
  private void pressAgainToExit() {
    long current = System.currentTimeMillis();
    long duration = (current - lastPressBackTime) / 1000;

    if (duration <= PRESS_AGAIN_LIMIT_DURATION) {
      runOnUiThread(
          new Runnable() {
            @Override
            public void run() {
              try {
                Thread.sleep(200);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }

              //                    exitApp();
              finish();
            }
          });
    } else {
      lastPressBackTime = current;
      ToastUtil.showToast(getApplicationContext(), getString(R.string.press_again_to_exit));
    }
  }
Example #27
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    final ZLApplication application = ZLApplication.Instance();
    final ZLKeyBindings bindings = application.keyBindings();

    if (bindings.hasBinding(keyCode, true) || bindings.hasBinding(keyCode, false)) {
      if (myKeyUnderTracking != -1) {
        if (myKeyUnderTracking == keyCode) {
          return true;
        } else {
          myKeyUnderTracking = -1;
        }
      }
      if (bindings.hasBinding(keyCode, true)) {
        myKeyUnderTracking = keyCode;
        myTrackingStartTime = System.currentTimeMillis();
        return true;
      } else {
        return application.runActionByKey(keyCode, false);
      }
    } else {
      return false;
    }
  }
 // ==============================================================================
 static {
   System.loadLibrary("juce_jni");
 }
Example #29
0
 // Load the .so
 public void loadLibraries() {
   for (String lib : getLibraries()) {
     System.loadLibrary(lib);
   }
 }
Example #30
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);
  }