레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Android인 게시물을 표시합니다. 모든 게시물 표시

4/22/2014

Cb3 A20-compiling Android Image For Cubietruck

Cb3 A20-compiling Android Image For Cubietruck

About this Article

Download the source code

$mkdir cubietruck-android && cd cubietruck-android
$wget http://dl.cubieboard.org/software/a20-cubieboard/android/A20-android-4.2.tar.xz
$tar -xvf A20-android-4.2.tar.xz

Compiling image

After get the source code,you could use common to build it as follow:

Build Linux kernel

$cd lichee/
$cp linux-3.3/arch/arm/configs/cubietruck_defconfig linux-3.3/arch/arm/configs/sun7ismp_android_defconfig
$./build.sh -p sun7i_android 
Start Building:

Success Building:

Build Android image

$cd ../android42
$source build/envsetup.sh
$lunch 16 (select sugar_cubietruck-eng)
$extract-bsp
$make -j8
Finish building:

Pack Final image:
$pack
Pack success:

Install image

The final image is at /lichee/tools/pack/sun7i_android_sugar-cubietruck.img
You can use Livesuit to install it

1/22/2014

android get phone number and phone device id


-- Get Phone Number.

1. AndroidManifest.xm permission.

android.permission.READ_PHONE_STATE



import ..

import android.content.Context;
import android.telephony.TelephonyManager;

public String getPhoneNumber()
{
     TelephonyManager tmgr =       (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 return tmgr.getLine1Number();
}

// get device id
public String getDeviceId()
{
 TelephonyManager tmgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 return tmgr.getDeviceId();
}

12/16/2013

android ndk r9b - Compile issue

Compile option. issue

APP_CFLAGS += -Wno-error=format-security

#ifdef _DEBUG
LLOGI(...)  __
#else
LLOGI(...) do {} while(0)
#endif

11/29/2013

android call intent the other package. example source code.

package lowmans.test.MyTest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MyTest extends Activity {
private Intent intent;
private final String packageName = "com.android.music";   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        intent = this.getPackageManager().getLaunchIntentForPackage(packageName);
        Button btn  = (Button)findViewById(R.id.Button01);
        btn.setOnClickListener(new OnClickListener(){
         public void onClick(View v){
         MyTest.this.startActivity(intent);
         }
        });
    }

}

7/15/2013

google admob adView

1. https://kr.admob.com/
2. https://developers.google.com/mobile-ads-sdk/

3. bottom adView.

default center AdView,  ignored  android:gravity attribute


            android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

                    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/adview"
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom"
            ads:adSize="BANNER"
            ads:adUnitId="xxxxxxxxxxxxx"
            android:gravity="bottom|center" >
       

   

6/20/2013

Round View - android


- android Resource res drawable

rounded_corner_view.xml



http://schemas.android.com/apk/res/android
">   
   
   



Layour background


android:layout_height="wrap_content"
android:background="@drawable/rounded_corner_view"
android:padding="12dip"
android:orientation="vertical">
 

5/29/2013

gain root permission android

//
// method 1
//

Process p; 
try {
   p = Runtime.getRuntime().exec("su"); 

   DataOutputStream os = new DataOutputStream(p.getOutputStream()); 
   os.writeBytes("echo \"root?\" >/data/temporary.txt\n");


   os.writeBytes("exit\n"); 
   os.flush(); 
   try { 
      p.waitFor(); 
           if (p.exitValue() != 255) { 
              // TODO Code to run on success 
              toastMessage("root"); 
           } 
           else { 
               // TODO Code to run on unsuccessful 
               toastMessage("not root"); 
           } 
   } catch (InterruptedException e) { 
      // TODO Code to run in interrupted exception 
       toastMessage("not root"); 
   } 
} catch (IOException e) { 
   // TODO Code to run in input/output exception 
    toastMessage("not root"); 

5/25/2013

Android get Device ID & MAC address




-- getDeviceID()
TelephonyManager

public String getDeviceId ()

Return null if device ID is not available.
Requires Permission: READ_PHONE_STATE

-- MAC address

permission.

"android.permission.INTERNET">
"android.permission.ACCESS_NETWORK_STATE">
 
ConnectivityManager manager =
    (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

 

NetworkInfo ni = manager.getActiveNetworkInfo();
String netname = ni.getTypeName();
if (netname.equals("MOBILE")) {
    Log.d(TAG, "Network - > " + netname);
}else{
    Log.d(TAG, "Network - > " + netname);
}

WifiInfo wifiInfo = mWifiMgr.getConnectionInfo();
Log.d(TAG,"MAC:"+wifiInfo.getMacAddress());


5/22/2013

prevent duplication message Toast dialog android

Android에서 Toast를 사용할 때, 메시지 중복 지속되는 경우 방지.
  
Toast 변수를 선언한다. 
 
 
public static Toast mToast;
 
 onCreate() 또는 적절한 함수에서  1회 초기화한다. Toast.makeText()
{ 
    ...
    mToast = Toast.makeText(this, "null", Toast.LENGTH_SHORT); 
    ...
}
 
 
mToast 사용.
Func()
{
    mToast.setText(show this text); 
    mToast.show(); 
}
 
 
// 다른 클래스 ..모듈등에서 사용하기 편하게 유틸리티 클래스 생성후 사용해도 무방하다.
 

class appGlobalUtil 
{ 
    public static Toast mToast; 
 
    public  toast_message(  message)
    {
        mToast.setText(message); 
        mToast.show(); 
    }

 
} 

5/16/2013

orientation event fix - android


Reacting to Configuration Changes

Start be adding the android:configChanges node to your Activity's manifest node

android:configChanges="keyboardHidden|orientation"

setContentView to force the GUI layout to be re-done in the new orientation.


@Override
public void onConfigurationChanged(Configuration newConfig) {
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.myLayout);
}