Monthly Archives: January 2012

How to pass parameters back from intent

Tonight I ran across the issue of, “How do I send a result back to the parent that spawned an intent?”

After finding out that it is nearly impossible to pass instances of objects to the intent, I decided why not send the result back from the spawned intent.

To do something like this, use the following code to spawn the child intent:

//Starting a new Intent
Intent intent = new Intent(getApplicationContext(), whateverClass.class);

// Maybe add a param or two?
intent.putExtra("someParam", paramValue);

// starting new activity

When you are done with the intent, use this code to close it.

Intent intent=new Intent();
intent.putExtra("myParam", thiscouldbeastringvariable);
intent.putExtra("mySecondParam", thiscouldbeanintvaraible);
setResult(RESULT_OK, intent);

Lastly, here is how we process our result given from the child:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (SOMEINTEGERSHOULDGOHERE): // this was the integer you used to spawn the activity previously
if (resultCode == Activity.RESULT_OK) {
// Do whatever you want here.
// data.getStringExtra("ThisGetsOurParamBack");

This is basically how to send data, process it in a new activity/intent, and then spit the results back to the parent.

Pulling Active Directory account info via alias email address

I have been working on a PHP project that interfaces with active directory through LDAP.  I noticed that some accounts weren’t being resolved via email address.  I thought, hmm this is strange…  After a few hours, I finally figured out that the issue was due to an alias email address.  By default, the “mail” attribute only has the main email address listed, so any alias addresses will not be searched upon lookup.


Use this query to select an item from AD via its alias email address:

(proxyAddresses=smtp:[email protected])

Generating a SSL Cert with Apache & openSSL

Registering a SSL cert is always kind of a mystery for me. You always have to use a crazy long command line command and the wizard always asks funky questions. Hopefully this tutorial will help clarify the process.

First run the following command:

openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

And what the command does is it is generating a 256bit SSL certificate. RSA:1024 would generate a 128bit certificate. When the process has finished, you will have yourdomain.key and yourdomain.csr. yourdomain.key should NOT be distributed. This is your key to decrypt your traffic. The CSR should be presented to your CA (certificate authority).

As far as the generation process goes, you will be presented with a few questions:
Country: The two-letter International Organization for Standardization (ISO) format country code for where your organization is legally registered. This would be US for the United States.
State or Province: Name of the state or province where your organization is located. Write out the name in full.
City or Locality: Name of the city where your organization is registered/located. Write out the name in full.
Organization Unit: This may be left blank. However, if you are a company, you may want to put your company nickname here. I.e. Vooba instead of Vooba LLC
Organization: Vooba LLC
Passphrase: Depending on your registrar, you can/can’t use this. If you can’t use it, I recommend finding a different company. Use a strong password here.
Common Name: The fully-qualified domain name (FQDN), or URL, you want to secure. If you are not using a wild-card domain (*, use This will allow and to be secured. If you only secure, will be invalid.

Hope this helps and clarifies the process!

Errors From Package Manager in Ubuntu 11.10

Getting the following message from Package Manager in Ubuntu 11.10?

Requires installation of untrusted packages
The action would require the installation of packages from not authenticated sources.

And when you click on the Details dropdown it shows all of the packages that need to downloaded?

Run the following commands:

cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get update

These commands will save a backup of the old lists and then create a new lists folder.

More information can be found here.

How to make textview stay visible with softkeyboard

If you have a textview that spans a few lines, but have buttons or something else below the textview that you would like to be shown, you can have the textview object be resized automatically to make room for Android’s softkeyboard. To do this, simply add one line to your AndroidManifest.xml file.


This line of code should go inside of the

android:windowSoftInputMode="adjustResize" >

How to link text in Android

One of the weirdest things I stumbled across was the ability to hyperlink text in the Android environment.  Here is how to hyperlink text and then make it clickable.

TextView txtTheLink = (TextView)findViewById(; // Grab our textview/whatever with the HTML
txtTheLink.setText(Html.fromHtml("<a href=\"\">Go to Vooba!</a>")); // Convert from HTML to remove the HTML tag>
txtLinks.setMovementMethod(LinkMovementMethod.getInstance()); // Activate the link

Hope this helps!