@Override protected void onResume() { super.onResume(); final String intentAnswerId = getIntent().getExtras().getString(INTENT_ANSWER_EXTRA); IntentAnswer.getIntentAnswer( intentAnswerId, new GetCallback<IntentAnswer>() { @Override public void done(IntentAnswer intentAnswer, ParseException error) { if (error == null) { updateView(intentAnswer); } else { Log.e(TAG, "Cannot load intent", error); // Let's update the data and try again fetchIntentAnswer(intentAnswerId); } } }); registerNotificationReceiver(); ActionLog.log("resumed intent answer activity", intentAnswerId); AppEventsLogger.activateApp(this); }
@Override protected void onPause() { super.onPause(); // Save read flag intentAnswer.saveInBackground(); if (newMessageListener != null) { messagesRef.removeEventListener(newMessageListener); } if (chatStatusListener != null) { friendTypingRef.removeEventListener(chatStatusListener); } if (onlineStatusListener != null) { friendOnlineRef.removeEventListener(onlineStatusListener); } if (userTypingRef != null) { userTypingRef.setValue(false); } if (receiver != null) { unregisterReceiver(receiver); } ActionLog.log("paused intent answer activity"); AppEventsLogger.deactivateApp(this); }
@Override protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && requestCode == REQUEST_SELECT_FILE && data != null) { ActionLog.log("chose photo from gallery"); Uri selectedImageUri = data.getData(); String tempPath = FileTools.getRealPathFromURI(this, selectedImageUri); sendImageMessage(tempPath); } if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) { ActionLog.log("took photo"); sendImageMessage(mCurrentPhotoPath); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: android.content.Intent upIntent = NavUtils.getParentActivityIntent(this); if (NavUtils.shouldUpRecreateTask(this, upIntent)) { TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities(); } else { NavUtils.navigateUpTo(this, upIntent); } return true; case R.id.action_from_gallery: ActionLog.log("gallery opened"); openGallery(); return true; case R.id.action_take_photo: ActionLog.log("camera opened"); dispatchTakePictureIntent(); return true; } return super.onOptionsItemSelected(item); }