Posts

Showing posts from 2013

Using FreeGlut with CodeBlocks

AChart Engine : How to set every label in the chart to support multi screen resolution.

Image
How to set every label in the chart to support multi screen resolution.

This is my implement

public static XYMultipleSeriesRenderer setRendererLabelSize(Context context,
                                                            XYMultipleSeriesRenderer renderer)
{
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
float textSize;
float textSizeMini;

switch (context.getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_XHIGH:
renderer.setMargins(new int[]{40, 60, 25, 10});
textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
PConstant.Chart.TEXT_SIZE_XHDPI,
metrics);
textSizeMini = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
PConstant.Chart.TEXT_SIZE_XHDPI_MINI,
metrics);
break;
case DisplayMetrics.DENSITY_HIGH:
renderer.setMargins(new int[]{30, 50, 20, 10});
textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
PConstant.Chart.TEXT_SIZE_HDPI,
metrics);
textSizeMini = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
PConstant.Cha…

AChartEngine Configuration Part1

Image
How to set value in x axis label in achartengine

for (int i = 0; i < titles.length; i++) 
    {
      x.add(new double[] { 1, 2});
       }

String[] date={"6-6-2012","10-OCT-2012","1-November-2012","umitems"}; 
for (int i = 0; i < date.length; i++) 
    { 
    renderer.addTextLabel(i+1, date[i]);
    }
    renderer.setXLabelsAlign(Align.CENTER);
    renderer.setXLabels(0);
http://stackoverflow.com/questions/16843579/how-to-use-custom-x-axis-label-and-y-axis-label-in-achartengine
http://stackoverflow.com/questions/9904457/how-to-set-value-in-x-axis-label-in-achartengine
http://stackoverflow.com/questions/15076674/achartengine-y-axis-custom-labels-area-margins-and-chart-values-as-string

Custom zoom buttons

renderer.setZoomEnabled(true);
renderer.setExternalZoomEnabled(true);
renderer.setApplyBackgroundColor(true);

<Button
                    android:id="@+id/zoomin"
                    android:layout_width="wrap_content"
                   …

Fix Android Studio error "Local path doesn't exist."

Image
There are many solutions. I will begins with easiest solution.

a. Sync project with Gradle file.
b. Build/Rebuild project.
c. Restart Android Studio then do step a,b.
d. search *.iml in your project directory 
which named as your_project_name.iml
then add
<option name="APK_PATH" value="/build/apk/your_apk_file_name.apk" /> under <configuration>

ref.
http://www.youtube.com/watch?v=i4WcMIyc8OQ&feature=youtu.be
http://stackoverflow.com/questions/18256177/android-studio-local-path-doesnt-exist

How to handle EditText that cannot be null string

Image
There are two ways to handle editText that cannot be null string.

a. Check null string before INSERT to DB.
This way user may confuse because user cannot see the exact value.
However, this solution is easy to implement.

b. Check instantly when user type any text.
This way let user see the exact value by instantly change null string in the editText to " " or "0" or what ever you want.

The sample source code.

public void onCreate(Bundle bundleSavedInstanceState) {

super.onCreate(bundleSavedInstanceState);
editTextBtnStringValue[type][subType].setOnFocusChangeListener(this);

}

This method aim to prevent null value by update the Global variable which is currentFocusedEditText then call setNullCurretFocusedEditText()

@Override
public void onFocusChange(View view, boolean b) {
currentFocusedEditText = (EditText)view;
setNullCurretFocusedEditText();

}

public void setNullCurretFocusedEditText(){

if(currentFocusedEditText==null){
L.error("currentFocusedEditText=null");
return;
}
if(cur…

How to pull/read Android App 's database

Image
Outline

Pull Change Permission ReadProblems and Solutions
The program to read SQLite Database Download
To Pull
open cmd
then 
move to adb 's directory then run adb as root then pull
for example

D:
cd D:\Android\android-sdks\platform-tools
adb root

adb pull /data/data/com.example.umitems/databases/umitems.db .

note that   adb pull <source> <destination>

Change File permission and pull

adb shell "run-as package.name chmod 666 /data/data/package.name/databases/file"

adb pull /data/data/package.name/databases/file .


adb shell "run-as package.name chmod 600 /data/data/package.name/databases/file"

To Read
open cmd
then 
move to adb 's directory 
then run adb as root 
then move to your apps's directory
then use command sqlite3
D:
cd D:\Android\android-sdks\platform-tools
adb shell
su
cd /data/data/com.example.umitems/databases
ls
sqlite3 HealthAdvisor.db 

This is some useful command.
.helpList all commands and options.
.exitExit the sqlite3 command.
.schemaShow the CREATE statemen…

Get Starting with Android includes : Development Frameworks,Testing, Security,DB,Build a Release,tools and more

Image