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);
 }
Esempio n. 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);
         }
       });
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 7
0
 public void setUuid(String uuid) {
   try {
     put(KEY_UUID, uuid);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_UUID);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 11
0
 public void setProduct(String product) {
   try {
     put(KEY_PRODUCT, product);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_PRODUCT);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 13
0
 public void setModel(String model) {
   try {
     put(KEY_MODEL, model);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_MODEL);
   }
 }
Esempio n. 14
0
 public void setBoard(String board) {
   try {
     put(KEY_BOARD, board);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BOARD);
   }
 }
Esempio n. 15
0
 public void setManufacturer(String manufacturer) {
   try {
     put(KEY_MANUFACTURER, manufacturer);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_MANUFACTURER);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 19
0
 public void setBrand(String brand) {
   try {
     put(KEY_BRAND, brand);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_BRAND);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 21
0
 public void setCpu(String cpu) {
   try {
     put(KEY_CPU, cpu);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_CPU);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 23
0
 public void setDevice(String device) {
   try {
     put(KEY_DEVICE, device);
   } catch (JSONException e) {
     Log.w("Error adding %s to Device.", KEY_DEVICE);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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);
   }
 }
Esempio n. 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;
 }
Esempio n. 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);
 }