Thursday, February 28, 2013

Customize your ACTION_CHOOSER Intent

For an Android Intent chooser, it is possible to either remove an Intent or add an custom Intent, this is how we do it:

List<Intent> targetedShareIntents = new ArrayList<Intent>();

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.blogspot.com");

List<ResolveInfo> resInfo = this.getPackageManager().queryIntentActivities(intent, 0);

for (ResolveInfo resolveInfo : resInfo) {
   String packageName = resolveInfo.activityInfo.packageName;

   Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
   targetedShareIntent.setType("text/plain");
   targetedShareIntent.putExtra(Intent.EXTRA_TEXT, "http://www.blogspot.com");
   targetedShareIntent.setPackage(packageName);

   if (!packageName.equals("com.facebook.katana")) { // Remove Facebook Intent share
      targetedShareIntents.add(targetedShareIntent);
   }
  }

// Add my own activity in the share Intent chooser
Intent i = new Intent(this, NextActivity.class);
targetedShareIntents.add(i);

Intent chooserIntent = Intent.createChooser(
   targetedShareIntents.remove(0), "Select app to share");

chooserIntent.putExtra(
   Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));

startActivity(chooserIntent);

Very nice reference from the following posts:

Sunday, January 13, 2013

[Windows] System Update Readiness Tool

To avoid Windows crash during system update, consider using the System Update Readiness Tool before doing the actual update, more information at:

    http://windows.microsoft.com/en-US/windows7/What-is-the-System-Update-Readiness-Tool

Thursday, January 3, 2013

Adjusting the screen resolution of BlueStack

The resolution can be changed by editing the BlueStack's registry:

HKLM\SOFTWARE\BlueStacks\Guests\Android\FrameBuffer\0\Height

and

HKLM\SOFTWARE\BlueStacks\Guests\Android\FrameBuffer\0\Width



Wednesday, November 14, 2012

Side notes on Android Dev

  1. To make your subclassed ViewPager (android.support.v4.view.ViewPager) work, prepare both the constructors in your class:
    • ViewPager(Context context)
    • ViewPager(Context context, AttributeSet attrs)
  2. In ActionBarSherlock, if you can't get the loading icon work, i.e. setSupportProgressBarIndeterminateVisibility( ) just got no effect at all, then you are very likely have a wrong Window class (android.view.Window) imported. You should include the ActionBarSherlock Window class instead.
    • com.actionbarsherlock.view.Window

Friday, September 21, 2012

Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver error

If you ever come up with the error using ChooserActivity with the Android emulator, you probably don't need to be worried.

It's basically because you only have a single choice to start the intent (e.g. send a message, choose a audio file, choose a picture, etc., in the emulator).

There is just no way to show you the option dialog, and the exception raised. Read the explanation in the following:

http://stackoverflow.com/questions/11308260/chooser-activity-leak-android

Tuesday, September 18, 2012

Android 2.2 SDK with strings.xml having multiple %s


When building the SearchableDictionary examples using 2.2 SDK, the strings.xml contains the following which fails the compilation:

<plurals name="search_results"> 
  <item quantity="one">%d result for \"%s\": </item>
  <item quantity="other">%d results for \"%s\": </item>
</plurals>

We need to change them to the following in order make it compiled:


<plurals name="search_results"> 
  <item quantity="one">%1$d result for \"%2$s\": </item>
  <item quantity="other">%1$d results for \"%2$s\": </item>
</plurals>


Reference:

Tuesday, September 11, 2012

Quick notes on Dojo 1.8

Just a quick notes on dojo 1.8. For example, if I want to use the Color object in dojo. I will:

   var Color;

   require(["dojo/_base/Color"], function(c) {
      Color = c;
   });

Then I can use the variable Color after the initialization is done. Am I correct? Should it be used in another way? :-)


Thursday, August 30, 2012

Upgrading from ArcGIS Android API v1.1 to v2.0

If you got a ArcGIS Android Project using ArcGIS API v1.1 and switch to v2.0, you will have a runtime exception when you do a pan action in the map view.

   FATAL EXCEPTION: main
   java.lang.UnsatisfiedLinkError: nativeSetAnimating
   com.esri.android.map.MapSurface.nativeSetAnimating(Native Method)
   ...

To solve this problem, you need to:
  1. Create a new ArcGIS Android project using v2.0
  2. Copy the files "libs/armeabi/libGLMapCore.so" and "libs/armeabi-v7a/libGLMapCore.so" back to your original v1.0 project directory
Very stupid right? But choose to use this product is stupid enough.


Tuesday, August 28, 2012

DOJO: Tab ordering in TabContainer

The tabContainer.getChildren( ) method returns a list of tab widget (ContentPane) in the container using the following way:

    dijit.findWidgets(tabContainer.containerNode)

However, if you did some drag and drop actions on the tab button list to rearrange the tab ordering, the tab sequence did not changed actually. To get a modified / correct ordered list, you may try to override the getChildren( ) method:

    myTabContainer.getChildren = function() {
        var list = this.tablist.getChildren();
        var rsltList = [];
        for (var idx=0; idx<list.length; idx++) {
           rsltList.push(list[idx].tab);
        }
        return rsltList;
    }

Noticed the underlined "tab" member variable in the code, you need to manually assign it when your tab page is created. Or you may find a way / method to get the Tab page object (ContentPane) via the Tab Button.

If you got any better method, please let me know :-)

Thursday, August 23, 2012

Drag and Drop of Tab in Dojo

Check the following example for a hint to do drag and drop of tab page in Dojo:

CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...