Wednesday, May 22, 2013

Executing PowerShell script

  1. Check your execution policy:
    PS> Get-ExecutionPolicy
  2. The execution policy is "Restricted" by default
  3. Change it to "Unrestricted"
    PS> Set-ExecutionPolicy Unrestricted
  4. Then you can run your script
    e.g. PS> .\scriptfile.ps1
Ref: http://ithelp.ithome.com.tw/question/10028377

Thursday, May 2, 2013

ESRI ArcGIS JS API version 3.4 hiding the Dojo Dnd style "dojoDndAvatar"

For ArcGIS JS API v3.4, if you include "esri.css" in your project, then your Dojo Dnd Avatar (the floating hints while you're doing drag and drop) will be disappeared.

Why? Because in "esri.css", esri.css got the following style:

     .dojoDndAvatar {display: none;}

God... What the hell ESRI guys are doing ?!

Friday, April 19, 2013

Avoid Android drawable resource to be scaled automatically

You know, you can have drawable images in Android (e.g. /res/drawable), you normally have it rescaled automatically according to your device dpi (e.g. ldpi, mdpi, hdpi, etc).

If you just don't want Android to scale it for, put your graphic files in /res/drawable-nodpi.

Reference: http://blog.pseudoblue.com/2010/11/15/disable-pre-scaling-of-android-image-resources/

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? :-)


CSP on Apache

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