トラッキング コード

12/28/2013

How to use a Sensor of "TYPE_STEP_DETECTOR"

A sensor of this type triggers an event each time a step is taken by the user.

http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_DETECTOR


Initialize Sensor

We have to get a Sensor's Object from SensorManager.
Set the type "Sensor.TYPE_STEP_DETECTOR".
public class StepCounterActivity extends Activity {
    private SensorManager mSensorManager;
    private Sensor mStepSensor;
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextView = (TextView) findViewById(R.id.text_step);

        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);

    }

    protected void onResume() {
        super.onResume();
        mSensorManager.registerListener(mSensorEventListener, mStepSensor,
                SensorManager.SENSOR_DELAY_NORMAL);
    }

    protected void onPause() {
        super.onPause();
        mSensorManager.unregisterListener(mSensorEventListener);
    }


Create a SensorListener

We can get a trigger from onSensorChanged.

    private SensorEventListener mSensorEventListener = new SensorEventListener() {
        private int mStep;

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        }

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (event.values[0] == 1.0f) {
                mStep++;
            }
            mTextView.setText(Integer.toString(mStep));
        }
    };

12/27/2013

How to use a Sensor of "TYPE_STEP_COUNTER"

Android API 19 add Sensor of "TYPE_STEP_COUNTER".

http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER


Initialize Sensor

We have to get a Sensor's Object from SensorManager.
Set the type "Sensor.TYPE_STEP_COUNTER".
public class StepCounterActivity extends Activity {
    private SensorManager mSensorManager;
    private Sensor mStepSensor;
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextView = (TextView) findViewById(R.id.text_step);

        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);

    }

    protected void onResume() {
        super.onResume();
        mSensorManager.registerListener(mSensorEventListener, mStepSensor,
                SensorManager.SENSOR_DELAY_NORMAL);
    }

    protected void onPause() {
        super.onPause();
        mSensorManager.unregisterListener(mSensorEventListener);
    }


Create a SensorListener

We can get a step from onSensorChanged.
"event.values[0]" is a step counter.A sensor of this type returns the number of steps taken by the user since the last reboot while activated. The value is returned as a float (with the fractional part set to zero) and is reset to zero only on a system reboot.

    private SensorEventListener mSensorEventListener = new SensorEventListener() {
        private float mStepOffset;

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        }

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (mStepOffset == 0) {
                mStepOffset = event.values[0];
            }
            mTextView.setText(Float.toString(event.values[0] - mStepOffset));
        }
    };

12/21/2013

How to use the DrawerLayout like a slide menu of the "Google Play"

Android Developers Site

http://developer.android.com/training/implementing-navigation/nav-drawer.html


Creat a layout file

You shoud create a layout file using DrawerLayout in android.support.v4.widget.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- The main content view -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- The navigation drawer -->

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>

Set in Activity

We set ActionBarDrawerToggle.
We call "setHomeButtonEnabled(true)" and "setDisplayHomeAsUpEnabled(true)", in order to enable the click of an icon on ActionBar.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawerlayout);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        mTitle = getTitle();
        mDrawerTitle = getText(R.string.drawer_open);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(
                this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
                R.string.drawer_open, /* "open drawer" description */
                R.string.drawer_close /* "close drawer" description */
                ) {

                    /**
                     * Called when a drawer has settled in a completely closed
                     * state.
                     */
                    public void onDrawerClosed(View view) {
                        getActionBar().setTitle(mTitle);
                    }

                    /**
                     * Called when a drawer has settled in a completely open
                     * state.
                     */
                    public void onDrawerOpened(View drawerView) {
                        getActionBar().setTitle(mDrawerTitle);
                    }
                };

        // Set the drawer toggle as the DrawerListener
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }

12/06/2013

Add OpenGL with hardware rendering on JellybeanOnBeaglebone_WithSGX for Beagle Bone Black

If you would like to use OpenGL ES 2.0 with hardware rendering, you should add modification.


Mod egl.cfg
\device\ti\beagleboard\egl.cfg

0 0 android
0 1 POWERVR_SGX530_125 <- add line !!

Mod build.prop
\device\ti\beagleboard\beagleboard.mk

PRODUCT_PROPERTY_OVERRIDES := \
net.dns1=8.8.8.8 \
net.dns2=8.8.4.4 \
ro.opengles.version=131072 <- add line !!

Building JellybeanOnBeaglebone_WithSGX for Beagle Bone Black

Get the Files
  $ repo init -u git://gitorious.org/rowboat/manifest.git -m rowboat-jb-am335x.xml
  $ repo sync $

Toolchain Setup
Setup the tool-chain path to point to arm-eabi- tools in prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/
  $ export PATH=/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
Build Boot Loader (MLO/u-boot)
Change directory to u-boot
  $ cd u-boot
Execute following commands
  $ make CROSS_COMPILE=arm-eabi- distclean
  $ make CROSS_COMPILE=arm-eabi- am335x_evm_config
  $ make CROSS_COMPILE=arm-eabi- 
Build Android, Kernel and SGX
  $ make TARGET_PRODUCT=beagleboneblack OMAPES=4.x
Create Root Filesystem Tarball
Prepare the root filesystem as follows:
  $ cd 
  $ make TARGET_PRODUCT=beagleboneblack fs_tarball
Flash SD Card
Copy compiled Images to image folder and create a bootable SD card as follows.
  $ mkdir image_folder
  $ cd image_folder
  $ cp ../kernel/arch/arm/boot/uImage .
  $ cp ../u-boot/MLO .
  $ cp ../u-boot/u-boot.img .
  $ cp ../external/ti_android_utilities/am335x/u-boot-env/uEnv_beagleboneblack.txt .
  $ cp ../out/target/product/beagleboneblack/rootfs.tar.bz2 .
  $ cp ../external/ti_android_utilities/am335x/mk-mmc/mkmmc-android.sh .
  $ sudo ./mkmmc-android.sh YOUR_SD_CARD MLO u-boot.img uImage uEnv_beagleboneblack.txt rootfs.tar.bz2

12/05/2013

TI official image of Android On Beagle Bone Black

You can get 'release information' of Beagle Bone Black's Android.
http://downloads.ti.com/sitara_android/esd/TI_Android_DevKit/TI_Android_JB_4_2_2_DevKit_4_1_1/index_FDS.html

I got offical TI image Of Android 4.2.2, and install to beagle bone black.


$ wget http://downloads.ti.com/sitara_android/esd/TI_Android_DevKit/TI_Android_JB_4_2_2_DevKit_4_1_1/exports/TI_Android_JB_4.2.2_DevKit_4.1.1_beagleboneblack.tar.gz
$ tar xzvf TI_Android_JB_4.2.2_DevKit_4.1.1_beagleboneblack.tar.gz
$ cd beagleboneblack
$ sudo ./mkmmc-android.sh /dev/


copyed to log.
Assuming Default Locations for Prebuilt Images
All data on /dev/sdb now will be destroyed! Continue? [y/n]
y
[Unmounting all existing partitions on the device ]
umount: /dev/sdb: not mounted
umount: /dev/sdb2: not mounted
[Partitioning /dev/sdb...]
Disk /dev/sdb doesn't contain a valid partition table
DISK SIZE - 7851737088 bytes
CYLINDERS - 954
[Making filesystems...]
[Copying files...]
[Copying START_HERE folder to boot partition]
umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[Copying all clips to data partition]
[Done]


Takes a long time to start Android...Please wait 10 minutes.

11/04/2013

Andoird 4.4 KitKat StatusBar



SystemServer

We can hide StatusBar, settiing of "config.disable_systemui" .

https://android.googlesource.com/platform/frameworks/base/+/android-4.4_r1/services/java/com/android/server/SystemServer.java
        boolean disableSystemUI = SystemProperties.getBoolean("config.disable_systemui", false);

            if (!disableSystemUI) {
                try {
                    Slog.i(TAG, "Status Bar");
                    statusBar = new StatusBarManagerService(context, wm);
                    ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
                } catch (Throwable e) {
                    reportWtf("starting StatusBarManagerService", e);
                }
            }


SystemUi

Delete "tablet" of folder. so not be used on JB!!

https://android.googlesource.com/platform/frameworks/base/+/android-4.4_r1/packages/SystemUI/src/com/android/systemui/statusbar/

10/17/2013

How to backup for Peak

memo:
adb shell
cd /dev/block
excute dd commond each of "mmcblk" file.
dd if=/dev/block/mmcblk0 of=/sdcard/peak_bk/mmcblk0
dd if=/dev/block/mmcblk0p1 of=/sdcard/peak_bk/mmcblk0p1
dd if=/dev/block/mmcblk0p10 of=/sdcard/peak_bk/mmcblk0p10
dd if=/dev/block/mmcblk0p11 of=/sdcard/peak_bk/mmcblk0p11
dd if=/dev/block/mmcblk0p12 of=/sdcard/peak_bk/mmcblk0p12
dd if=/dev/block/mmcblk0p13 of=/sdcard/peak_bk/mmcblk0p13
dd if=/dev/block/mmcblk0p14 of=/sdcard/peak_bk/mmcblk0p14
dd if=/dev/block/mmcblk0p15 of=/sdcard/peak_bk/mmcblk0p15
dd if=/dev/block/mmcblk0p16 of=/sdcard/peak_bk/mmcblk0p16
dd if=/dev/block/mmcblk0p17 of=/sdcard/peak_bk/mmcblk0p17
dd if=/dev/block/mmcblk0p18 of=/sdcard/peak_bk/mmcblk0p18
dd if=/dev/block/mmcblk0p19 of=/sdcard/peak_bk/mmcblk0p19
dd if=/dev/block/mmcblk0p2 of=/sdcard/peak_bk/mmcblk0p2
dd if=/dev/block/mmcblk0p20 of=/sdcard/peak_bk/mmcblk0p20
dd if=/dev/block/mmcblk0p21 of=/sdcard/peak_bk/mmcblk0p21
dd if=/dev/block/mmcblk0p3 of=/sdcard/peak_bk/mmcblk0p3
dd if=/dev/block/mmcblk0p4 of=/sdcard/peak_bk/mmcblk0p4
dd if=/dev/block/mmcblk0p5 of=/sdcard/peak_bk/mmcblk0p5
dd if=/dev/block/mmcblk0p6 of=/sdcard/peak_bk/mmcblk0p6
dd if=/dev/block/mmcblk0p7 of=/sdcard/peak_bk/mmcblk0p7
dd if=/dev/block/mmcblk0p8 of=/sdcard/peak_bk/mmcblk0p8
dd if=/dev/block/mmcblk0p9 of=/sdcard/peak_bk/mmcblk0p9
dd if=/dev/block/mmcblk1 of=/sdcard/peak_bk/mmcblk1
dd if=/dev/block/mmcblk1p1 of=/sdcard/peak_bk/mmcblk1p1

9/23/2013

Create a tab of like "Ingress Comm".

I created a tab of like "Ingress Comm".


Displayed Image

First, display only a tab. Display the View by pulling up the tab.




On pulling up the tab, display contens in View.

Code

It is published at Github, with Licence of "MIT".
https://github.com/baroqueworksdev/MyApiDemo/blob/master/src/jp/baroqueworksdev/myapidemo/view/SlidePanelView.java

7/28/2013

About AppOps in Android 4.3

Android 4.3 added "AppOps" whitch is like permission manager.


Points


  • added AppOpsManager, AppOpsService in the frameworks(Java Layer).
  • If you would like to use "AppOps", you can called getSystemService(Context.LAYOUT_INFLATER_SERVICE).
  • Each "Service" in frameworks decide to run operation, by obtaining a setting from the AppOpsService,
If you want to know more info, you should do grep "AppOpsManager.MODE_ALLOWED / MODE_IGNORED" in AOSP.




Create "AppOpsService" instance

AppOpsService is created in ActivityManagerService's constructor.

    private ActivityManagerService() {
        File systemDir = new File(dataDir, "system");
            :
        mAppOpsService = new AppOpsService(new File(systemDir, "appops.xml"));
            :
    }



Setting data of AppOpsManager

Setting data of AppOps is saved to xml file. Xml file is named "appops.xml". It is saved under the System directory.

public class AppOpsService extends IAppOpsService.Stub {
    public AppOpsService(File storagePath) {
        mFile = new AtomicFile(storagePath);
        mHandler = new Handler();
        readState();
    }

    void readState() {

    }
    void writeState() {

    }
}

Ckeck it

You should check many source in AOPS(android-4.3_r2.1).
Settings application
packages/apps/Settings/src/com/android/settings/applications
- AppOpsCategory.java
- AppOpsDetails.java
- AppOpsState.java
- AppOpsSummary.java


Frameworks
frameworks/base/core/java/android/app/ContextImpl.java
frameworks/base/core/java/android/app/AppOpsManager.java
frameworks/base/services/java/com/android/server/AppOpsService.java
frameworks/base/services/java/com/android/server/am/ActivityManagerService.java