private void sendMessage(final Activity activity) {
   SharedPreferences prefs =
       activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
   prefs
       .edit()
       .putBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, false)
       .commit();
   // Save the email.
   if (interaction.isAskForEmail()) {
     if (email != null && email.length() != 0) {
       PersonManager.storePersonEmail(activity, email.toString());
       Person person = PersonManager.storePersonAndReturnDiff(activity);
       if (person != null) {
         Log.d("Person was updated.");
         Log.v(person.toString());
         ApptentiveDatabase.getInstance(activity).addPayload(person);
       } else {
         Log.d("Person was not updated.");
       }
     }
   }
   // Send the message.
   final TextMessage textMessage = new TextMessage();
   textMessage.setBody(message.toString());
   textMessage.setRead(true);
   /*
   		// TODO: Figure out how to add custom data here.
   		textMessage.setCustomData(customData);
   		customData = null;
   */
   MessageManager.sendMessage(activity, textMessage);
 }
Example #2
0
 public static void showSurvey(
     final ForgeTask task, @ForgeParam("tags") final JsonArray surveyTags) {
   Log.e("Tags: " + surveyTags.toString());
   // Remove duplicates and empty string tags.
   Set<String> tagSet = new HashSet<String>();
   for (int i = 0; i < surveyTags.size(); i++) {
     String tag = surveyTags.get(i).getAsString();
     if (tag.length() > 0) {
       tagSet.add(tag);
     }
   }
   final String[] tags = tagSet.toArray(new String[] {});
   task.performUI(
       new Runnable() {
         public void run() {
           Apptentive.showSurvey(
               ForgeApp.getActivity(),
               new OnSurveyFinishedListener() {
                 @Override
                 public void onSurveyFinished(boolean completed) {
                   Log.d(
                       "Firing apptentive.surveyFinishedsurvey event with parameter {%b}",
                       completed);
                   ForgeApp.event("apptentive.surveyFinished", new JsonPrimitive(completed));
                 }
               },
               tags);
         }
       });
 }
Example #3
0
 public void setCurrentCarrier(String currentCarrier) {
   try {
     put(KEY_CURRENT_CARRIER, currentCarrier);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_CURRENT_CARRIER);
   }
 }
 public void setConfigurationCacheExpirationMillis(long configurationCacheExpirationMillis) {
   try {
     put(KEY_CONFIGURATION_CACHE_EXPIRATION_MILLIS, configurationCacheExpirationMillis);
   } catch (JSONException e) {
     Log.w("Error adding %s to Configuration.", KEY_CONFIGURATION_CACHE_EXPIRATION_MILLIS);
   }
 }
Example #5
0
 public void setOsVersion(String osVersion) {
   try {
     put(KEY_OS_VERSION, osVersion);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_OS_VERSION);
   }
 }
Example #6
0
 public void setBuildId(String buildId) {
   try {
     put(KEY_BUILD_ID, buildId);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BUILD_ID);
   }
 }
Example #7
0
 public void setUuid(String uuid) {
   try {
     put(KEY_UUID, uuid);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_UUID);
   }
 }
Example #8
0
 public void setNetworkType(String networkType) {
   try {
     put(KEY_NETWORK_TYPE, networkType);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_NETWORK_TYPE);
   }
 }
Example #9
0
 public void setLocaleCountryCode(String localeCountryCode) {
   try {
     put(KEY_LOCALE_COUNTRY_CODE, localeCountryCode);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_LOCALE_COUNTRY_CODE);
   }
 }
Example #10
0
 public void setLocaleRaw(String localeRaw) {
   try {
     put(KEY_LOCALE_RAW, localeRaw);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_LOCALE_RAW);
   }
 }
Example #11
0
 public void setProduct(String product) {
   try {
     put(KEY_PRODUCT, product);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_PRODUCT);
   }
 }
Example #12
0
 public void setCustomData(CustomData customData) {
   try {
     put(KEY_CUSTOM_DATA, customData);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_CUSTOM_DATA);
   }
 }
Example #13
0
 public void setModel(String model) {
   try {
     put(KEY_MODEL, model);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_MODEL);
   }
 }
Example #14
0
 public void setBoard(String board) {
   try {
     put(KEY_BOARD, board);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BOARD);
   }
 }
Example #15
0
 public void setManufacturer(String manufacturer) {
   try {
     put(KEY_MANUFACTURER, manufacturer);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_MANUFACTURER);
   }
 }
Example #16
0
 public void setOsApiLevel(String osApiLevel) {
   try {
     put(KEY_OS_API_LEVEL, osApiLevel);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_OS_API_LEVEL);
   }
 }
Example #17
0
 public void setOsBuild(String osBuild) {
   try {
     put(KEY_OS_BUILD, osBuild);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_OS_BUILD);
   }
 }
Example #18
0
 public void setBootloaderVersion(String bootloaderVersion) {
   try {
     put(KEY_BOOTLOADER_VERSION, bootloaderVersion);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BOOTLOADER_VERSION);
   }
 }
Example #19
0
 public void setBrand(String brand) {
   try {
     put(KEY_BRAND, brand);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BRAND);
   }
 }
Example #20
0
 public void setRadioVersion(String radioVersion) {
   try {
     put(KEY_RADIO_VERSION, radioVersion);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_RADIO_VERSION);
   }
 }
Example #21
0
 public void setCpu(String cpu) {
   try {
     put(KEY_CPU, cpu);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_CPU);
   }
 }
Example #22
0
 public void setIntegrationConfig(CustomData integrationConfig) {
   try {
     put(KEY_INTEGRATION_CONFIG, integrationConfig);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_INTEGRATION_CONFIG);
   }
 }
Example #23
0
 public void setDevice(String device) {
   try {
     put(KEY_DEVICE, device);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_DEVICE);
   }
 }
Example #24
0
 public void setLocaleLanguageCode(String localeLanguageCode) {
   try {
     put(KEY_LOCALE_LANGUAGE_CODE, localeLanguageCode);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_LOCALE_LANGUAGE_CODE);
   }
 }
Example #25
0
 public void setOsName(String osName) {
   try {
     put(KEY_OS_NAME, osName);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_OS_NAME);
   }
 }
Example #26
0
 public void setUtcOffset(String utcOffset) {
   try {
     put(KEY_UTC_OFFSET, utcOffset);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_UTC_OFFSET);
   }
 }
Example #27
0
 public void setBuildType(String buildType) {
   try {
     put(KEY_BUILD_TYPE, buildType);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BUILD_TYPE);
   }
 }
 public static synchronized void start(Context context) {
   appContext = context.getApplicationContext();
   if (!running) {
     Log.i("Starting PayloadRunner.");
     running = true;
     new PayloadRunner().start();
   }
 }
 private Drawable getIconDrawableResourceId(Activity activity) {
   try {
     PackageManager pm = activity.getPackageManager();
     PackageInfo pi = pm.getPackageInfo(activity.getPackageName(), 0);
     return activity.getResources().getDrawable(pi.applicationInfo.icon);
   } catch (Exception e) {
     Log.e("Error loading app icon.", e);
   }
   return null;
 }
Example #30
0
 public static void isSurveyAvailable(
     final ForgeTask task, @ForgeParam("tags") final JsonArray surveyTags) {
   Log.e("Tags: " + surveyTags.toString());
   String[] tags = new String[surveyTags.size()];
   for (int i = 0; i < surveyTags.size(); i++) {
     tags[i] = surveyTags.get(i).getAsString();
   }
   boolean available = Apptentive.isSurveyAvailable(ForgeApp.getActivity(), tags);
   task.success(available);
 }