private void init(String eventType, String eventEvent, JSONObject eventPayload) {
   this.eventType = eventType;
   this.eventEvent = eventEvent;
   this.eventTimestamp = getTimestamp();
   this.eventMid = TiPlatformHelper.getMobileId();
   this.eventSid = TiPlatformHelper.getSessionId();
   this.eventAppGuid = TiPlatformHelper.getAppInfo().getGUID();
   this.eventPayload = eventPayload.toString();
   this.expandPayload = true;
 }
Пример #2
0
 public void postAppInfo() {
   TiPlatformHelper.initialize();
 }
Пример #3
0
  @Override
  /**
   * When the activity is created, this method adds it to the activity stack and fires a javascript
   * 'create' event.
   *
   * @param savedInstanceState Bundle of saved data.
   */
  protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "Activity " + this + " onCreate", Log.DEBUG_MODE);

    inForeground = true;
    TiApplication tiApp = getTiApp();

    if (tiApp.isRestartPending()) {
      super.onCreate(savedInstanceState);
      if (!isFinishing()) {
        finish();
      }
      return;
    }

    // If all the activities has been killed and the runtime has been disposed, we cannot recover
    // one
    // specific activity because the info of the top-most view proxy has been lost
    // (TiActivityWindows.dispose()).
    // In this case, we have to restart the app.
    if (TiBaseActivity.isUnsupportedReLaunch(this, savedInstanceState)) {
      Log.w(TAG, "Runtime has been disposed. Finishing.");
      super.onCreate(savedInstanceState);
      tiApp.scheduleRestart(250);
      finish();
      return;
    }

    TiApplication.addToActivityStack(this);

    // create the activity proxy here so that it is accessible from the activity in all cases
    activityProxy = new ActivityProxy(this);

    // Increment the reference count so we correctly clean up when all of our activities have been
    // destroyed
    KrollRuntime.incrementActivityRefCount();

    Intent intent = getIntent();
    if (intent != null) {
      if (intent.hasExtra(TiC.INTENT_PROPERTY_MESSENGER)) {
        messenger = (Messenger) intent.getParcelableExtra(TiC.INTENT_PROPERTY_MESSENGER);
        msgActivityCreatedId = intent.getIntExtra(TiC.INTENT_PROPERTY_MSG_ACTIVITY_CREATED_ID, -1);
        msgId = intent.getIntExtra(TiC.INTENT_PROPERTY_MSG_ID, -1);
      }

      if (intent.hasExtra(TiC.PROPERTY_WINDOW_PIXEL_FORMAT)) {
        getWindow()
            .setFormat(intent.getIntExtra(TiC.PROPERTY_WINDOW_PIXEL_FORMAT, PixelFormat.UNKNOWN));
      }
    }

    // Doing this on every create in case the activity is externally created.
    TiPlatformHelper.intializeDisplayMetrics(this);

    if (layout == null) {
      layout = createLayout();
    }
    if (intent != null && intent.hasExtra(TiC.PROPERTY_KEEP_SCREEN_ON)) {
      layout.setKeepScreenOn(
          intent.getBooleanExtra(TiC.PROPERTY_KEEP_SCREEN_ON, layout.getKeepScreenOn()));
    }

    super.onCreate(savedInstanceState);

    // we only want to set the current activity for good in the resume state but we need it right
    // now.
    // save off the existing current activity, set ourselves to be the new current activity
    // temporarily
    // so we don't run into problems when we give the proxy the event
    Activity tempCurrentActivity = tiApp.getCurrentActivity();
    tiApp.setCurrentActivity(this, this);

    windowCreated();

    if (activityProxy != null) {
      // Fire the sync event with a timeout, so the main thread won't be blocked too long to get an
      // ANR. (TIMOB-13253)
      activityProxy.fireSyncEvent(TiC.EVENT_CREATE, null, 4000);
    }

    // set the current activity back to what it was originally
    tiApp.setCurrentActivity(this, tempCurrentActivity);

    setContentView(layout);

    sendMessage(msgActivityCreatedId);
    // for backwards compatibility
    sendMessage(msgId);

    // store off the original orientation for the activity set in the AndroidManifest.xml
    // for later use
    originalOrientationMode = getRequestedOrientation();

    if (window != null) {
      window.onWindowActivityCreated();
    }
  }
Пример #4
0
 @Kroll.getProperty
 @Kroll.method
 public String getVersion() {
   return TiPlatformHelper.getVersion();
 }
Пример #5
0
 @Kroll.getProperty
 @Kroll.method
 public double getAvailableMemory() {
   return TiPlatformHelper.getAvailableMemory();
 }
Пример #6
0
 @Kroll.getProperty
 @Kroll.method
 public int getProcessorCount() {
   return TiPlatformHelper.getProcessorCount();
 }
Пример #7
0
 @Kroll.getProperty
 @Kroll.method
 public String getUsername() {
   return TiPlatformHelper.getUsername();
 }
Пример #8
0
 @Kroll.getProperty
 @Kroll.method
 public String getId() {
   return TiPlatformHelper.getMobileId();
 }
Пример #9
0
 @Kroll.getProperty
 @Kroll.method
 public String getMacaddress() {
   return TiPlatformHelper.getMacaddress();
 }
Пример #10
0
 @Kroll.method
 public String createUUID() {
   return TiPlatformHelper.createUUID();
 }
Пример #11
0
 @Kroll.getProperty
 @Kroll.method
 public String getNetmask() {
   return TiPlatformHelper.getNetmask();
 }
Пример #12
0
 @Kroll.getProperty
 @Kroll.method
 public String getArchitecture() {
   return TiPlatformHelper.getArchitecture();
 }