App Uri - Android Studio¶
Pulse also provides an “App Uri” capability for email address, telephone and http URL payload. This capability can pass specific information directly to an activity when an App is in the foreground.
Please refer to the demo app to see an example of receiving the information.
- To use Pulse’s “App Uri” feature whilst app is in the foreground, add a local BroadcastReceiver to the activities you want to be notified about. Then use the intent.getStringExtra method to get the content:
// email LocalBroadcastManager.getInstance(this.getApplicationContext()).registerReceiver(mAppUriEmailReceiver,new ntentFilter(PulseConstants.PULSE_APP_URI_EMAIL_RECEIVER)); private BroadcastReceiver mAppUriEmailReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { setPulseKey(intent.getStringExtra("key")); Toast.makeText(getApplicationContext(), "content = "+intent.getStringExtra(PulseConstants.PULSE_APP_URI_EMAIL_CONTENT),Toast.LENGTH_LONG).show(); } }; // http LocalBroadcastManager.getInstance(this.getApplicationContext()).registerReceiver(mAppUriHttpReceiver,new IntentFilter(PulseConstants.PULSE_APP_URI_HTTP_RECEIVER)); private BroadcastReceiver mAppUriHttpReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { setPulseKey(intent.getStringExtra("key")); Toast.makeText(getApplicationContext(), "content = "+intent.getStringExtra(PulseConstants.PULSE_APP_URI_HTTP_CONTENT),Toast.LENGTH_LONG).show(); } }; // telephone LocalBroadcastManager.getInstance(this.getApplicationContext()).registerReceiver(mAppUriTelReceiver,new IntentFilter(PulseConstants.PULSE_APP_URI_TEL_RECEIVER)); private BroadcastReceiver mAppUriTelReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { setPulseKey(intent.getStringExtra("key")); Toast.makeText(getApplicationContext(), "content = "+intent.getStringExtra(PulseConstants.PULSE_APP_URI_TEL_CONTENT),Toast.LENGTH_LONG).show(); } }; protected void setPulseKey(String key) { mApplication.getPulseSDKInstance().setPulseAppUrlKey(key); }