Monday, August 12, 2013

[Android] Service

[Reference]
http://www.vogella.com/articles/AndroidServices/article.html


[Android] 在 Service 中啟動 Activity
[Reference] http://www.myandroid.tw/bbs-topic-66.sea

!!很重要!!
Server要啟動Activity一定要加上 Intent.FLAG_ACTIVITY_NEW_TASK的Flag

Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

[Android] 用 bind 啟動 Service

Service 裏要有如下的程式,在 onBind 傳回 mBinder, Activity 裏的 onServiceConnected() 才能收到 bind 完成的訊號, 預設傳回 null 沒用。

public class LocalBinder extends Binder {
MusicService getService() {
return MusicService.this;
}
}
private final IBinder mBinder = new LocalBinder();
@Override
public IBinder onBind(Intent intent) {
return
mBinder;
}

Friday, August 2, 2013

Setup QT for Android on Windows (C++)

[Reference]

1. Download the following packages:
        QT
        The Android NDK
        Apache Ant v1.8 or later
        OpenJDK v6 or later

2. Install packages:
        QT: Install
        The Android SDK Tools: extract and update 
        The Android NDK: Extract (Cannot contain SPACE in folder path)
        Apache Ant: Extract (Cannot contain SPACE in folder path)
        OpenJDK: Install

3. Set Path for Qt Creator
    [Tools] [Option] [Android]: Assign path for SDK, NDK, ant and JDK







Friday, July 5, 2013

[Visual C++] Run-Time Check Failure #2 - Stack around the variable was corrupted

This run time error often happens when you try to write a string to a char[ ] whose size is smaller than the string.

ex:

char str[10];
char s10[] = "1234567890";

str[10] = 'a';         <----- error, size of str is 10, can only access str[0] ~ str[9]
strcpy( str, s10);   <----- error, size of s10 is 11, don't forget the end character '\0' or NULL

Wednesday, June 26, 2013

[TeeChart] Add custom vertical/horizontal axis to a chart

// Create a new line series
  TLineSeries *Series = new TLineSeries(Chart);

// Create a new custom vertical axis
  TChartAxis *vertaxis = new TChartAxis(Chart);
// Assign custom vertical axis
  Series->CustomVertAxis = vertaxis;
// Set axis position
  vertaxis->PositionPercent = 0; //percentage
// Set axis size
  vertaxis->StartPosition = 10;  //percentage
  vertaxis->EndPosition   = 50;  //percentage

// Create a new custom horizontal axis
  TChartAxis *horiaxis = new TChartAxis(Chart);
// Set new axis as horizontal
  horiaxis->Horizontal = true;   
  
  Series->CustomHorizAxis = horiaxis;
  horiaxis->PositionPercent = 0;
  horiaxis->StartPosition   = 30;
  horiaxis->EndPosition     = 60;

// Add line series to chart
  Chart->AddSeries(Series);

Tuesday, May 28, 2013

[Note] Zero-length empty base class

For some application, eg., M LiDAR Viewer, I have to set the value of [Zero-length empty base class] and [Zero-length empty class member functions] at [C++ Compiler Compatibility] to "True" ( default are False), or the application doesn't run correct.
Why?

[Reference]
http://docwiki.embarcadero.com/RADStudio/XE4/en/C%2B%2B_Compiler_Compatibility

 

Friday, April 12, 2013

[InstallAWare] Delete registry keys created by your application after it was installed

[Reference] http://www.installaware.com/FlashHelp/precedeuninstall.htm
                   http://www.installaware.com/FlashHelp/deleteregistry.htm


To delete registry keys created by your application after it was installed:

    Delete Registry
    This command deletes a value or an entire key from the system registry.
    Root
    Select the root of the delete operation using the drop down menu.
    Key
    Type the name of the key to delete (from).
    Value
    Type the value to delete. Leave empty to delete the default value. If you are deleting the entire key, this field is ignored.
    Delete Entire Key (and subkeys)
    Check this item to delete the entire key, along with any subkeys it contains.
    Delete Value Only
    Check this item to delete the named value only.
     Warning
    • Windows Installer does not provide an easily timed mechanism to delete registry keys. This action will not execute through the Windows Installer engine and is provided as a convenience for the setup developer.
    • We recommend you create all registry keys used by your application as part of your setup. Doing so assures Windows Installer will automatically remove all such keys upon uninstallation.

    Copyright© 1996-2013 InstallAware Software. All rights reserved.

    Tuesday, April 9, 2013

    Draw to TBitmap fail !

    [Reference] http://qc.embarcadero.com/wc/qcmain.aspx?d=43018


    At multi-thread program. The canvas handle of the Bitmap may be freed during the drawing procedure. So, lock the canvas before the drawing operation. And free after the drawing.
    Lock the canvas may reduce the performance. But sometimes you have to do this.

    Canvas->Lock();

    drawing....

    Canvas0->Unlock();

    [Qt] 執行檔需要哪些 Dll?

     1. 使用 Qt  的 windeployqt.exe 工具 (在 C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\)。   a. 把執行檔 myProgram.exe 放在某個資料夾。   b. 在檔案總管這個資料夾按 Shift 和滑鼠右鍵,開啟 Po...