2016년 10월 27일 목요일

android unique한 키값 가져오기


SERIAL 번호 알아 내기

serial 번호를 알아 내기 위해 아래와 같이 처리시
(String) Build.class.getField("SERIAL").get(null);

return 값이 unknown 발생되는 경우가 있음.

---------------------------------------------

android id 알아 내기

import android.provider.Settings.Secure;

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                        Secure.ANDROID_ID);

2016년 9월 6일 화요일

ubuntu windows에서 GUI로 원격 접속 하는 방법

ubuntu 16 버전 기준

- 원격 접속할 서버수정한다.
 
- xrdpp과 xfce4 프로그램을 설치 한다.
sudo apt-get update
sudo apt-get install xrdp
sudo apt-get install xfce4
- xsession 파일을 만든다.
echo xfce4-session >~/.xsession
- startwm.sh 파일을 수정한다. 아래 명령어로 파일을 수정한다.
sudo vi /etc/xrdp/startwm.sh
- 다음과 같이 수정한다.
#!/bin/sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

startxfce4
- xrdp 를 재시작 한다.
sudo service xrdp restart

- 원격 서버 접속 테스트
winKey + r 키를 눌러 실행창을 띄운다. > mstsc 입력후 enter
원격 데스크톱 연결 프로그램 이 실행 되면 원격 서버 ip를 입력하고 연결버튼을 누른다.

login to xrdp 창이 표시 되면
username과 password 입력 후 사용하면 된다.


2016년 9월 5일 월요일

android 영상을 VideoView 사이즈에 맞게 표시하기 ( 늘리기 )



VideoView를 상속 받는 클래스를 만든다.

public class MseVideoView extends VideoView{
    public MseVideoView(Context context) {
        super(context);    }

    @Override    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);        setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);    }
}

MainActivity 에서 VideoView 상속받은 MseVideoView에게 setLayoutParams 을 호출
mVideoView = (MseVideoView) findViewById(R.id.video_view);
mVideoView.setLayoutParams(lp);

FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(1280, 720);
lp.leftMargin = 0 ;lp.topMargin = 0;mVideoView.setLayoutParams(lp);

setLayoutParams 메소드가 호출되면 onMeasure 메소드가 호출된다.

영상이 FrameLayout.LayoutParams(1280, 720)를 통해 지정된 크키로 꽉차서 (늘려져서) 표시된다.




2016년 8월 11일 목요일

android AppCompat을 상속 받은 activity의 배경 투명 으로 만들기


AndroidManifest.xml
파일의 activity의 속성에 theme를 다음과 같이 한다
android:theme="@style/TransparentTheme"

res > values > styles.xml의 다은 내용을 추가 한다.
<style name="TransparentTheme" parent="@style/Theme.AppCompat">    
    <item name="android:background">@null</item>    
    <item name="background">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>    
<item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@null</item>
    <item name="windowNoTitle">true</item></style>
<color name="transparent">#00FFFFFF</color>


///////////// 추가 ////////////////
    <item name="android:windowIsTranslucent">true</item> 
    만 주게 되면 배경이 투명하게 됨.

    <item name="windowNoTitle">true</item></style>
    title 바가 없어짐.

끝.

2016년 8월 10일 수요일

javascript webgl 좌표를 -1에서 1 사이의 값으로 변환하기



- 좌표를 -1에서 1 사이의 값으로 변환하기
 + function normalizedPoint(x, y)
{
  // converts screen coordinates to -1 to 1
  var canvas = document.getElementById("2dcanvas");
    x = (x / canvas.width) * 2 - 1;
    y = (1 - (y / canvas.height)) * 2 - 1;
   
    return new Point(x, y);
}

2016년 7월 19일 화요일

server iis cross domain access 가능하도록

- 서비스하고 있는 site root 디렉토리에 
web.config 파일을 아래와 같이 수정,
파일이 없다면 파일 수정

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

- 컴퓨터 관리에서 처리하는 방법

컴퓨터 관리 > 서비스 및 응용 프로그램 > IIS > 사이트 > 사이트 이름 선택 > 
오른쪽의, HTTP 응답헤더 선택 
마우스 오른쪽 클릭 추가 선택 > 이름 : Access-Control-Allow-Origin  값 : *
확인   > 재시작

2016년 6월 13일 월요일

css border에 그림자 효과 주기

box-shadow: 10px 10px grey;

box-shadow: -10px -10px grey;

box-shadow: 10px 10px 20px grey;

box-shadow: 10px 10px 20px 5px grey;

box-shadow: 10px 10px 20px 5px grey inset;

box-shadow: 0px 0px 20px 10px rgba(102, 186, 255, 0.4);

box-shadow:64px 64px 24px 40px rgba(0,0,0,0.4),12px 12px 0px 18px rgba(0,0,0,0.4) inset;

box-shadow는 레이아웃에 영향을 미치지 않음

box-shadow: 10px 10px #BCE55C, 20px 20px #CEF279, 30px 30px #E4F7BA;

2016년 6월 7일 화요일

html 자식 div의 중앙 정렬





심플하게

<div id="bg" style="width: 20%;height: 20%;background-color: yellow;">
    <div id="item" style="width: 50%;height: 50%;background-color: red;    margin: auto;text-align: center;">        <p>item</p>    </div></div>
자식 div(item) 의 width 값과 margin:auto 가 있으면 부모 div(bg) width의 가운데에 위치함.

vertical 중앙으로 자식 div를 위치하고 싶을때 아래와 같이

<div id="bg" style="width: 200px;height: 200px;background-color: yellow;
    display: table-cell;vertical-align: middle;">    
    <div id="item" style="width: 100px;height: 100px;background-color: red;
    margin: auto;text-align: center;display: block;">
        <p>item</p>    
    </div>
</div>


-----------------------------------------

html  ==============================
<div id="container">
  <div id="block">
    <div class="menu-icon-style menu-text-style background-color-red no-margin-left"    >
  360vr vod
    </div>
    <div class="menu-icon-style menu-text-style">
      360 image
    </div>
</div>

css ================================

#container {
    width:600px;
    height:300px;
    background-color:#191970;
    text-align:center;
    vertical-align:middle;
    display:table-cell;
}
#block {  
    background-color:rgba(255, 215, 0, 0.54);;
    display:inline-block;
}
.menu-icon-style {
  width: 200px;height: 200px;
    background-color: green;float: left;
    border-radius: 20px;border: 5px solid yellow;
    text-align:middle;line-height:200px;
    margin-left: 50px;"
}

.menu-text-style{
    font-size: 27px;color: white;
    font-family: inherit;font-weight: bold;
}

.background-color-red {
  background-color: red;
}

.no-margin-left {
  margin-left:0px;
}

2016년 5월 30일 월요일

intellij 14버전에서 svn 사용하기




- settings > version control > subversion 선택하고
 General 탭에서 svn실행 파일 위치를 지정한다.
 Use command line client : ->
 ex) C:\Program Files\SlikSvn\bin\svn.exe

- 메뉴의 VCS > Browse > VCS repository > Browse Subversion Repository 선택

- SVN Repositories 창에서 New > Repository Location 을 선택
 주소를 입력
 ex) https://111.222.230.26/svn
 추가된 주소에서 하위디렉토리로 접근시 authentication 팝업창이 출력되면 name password 입력

- download할 폴더를 선택하고 checkout 눌르면 down 받을 폴더를 지정하여 ok 클릭


   참고
 - 추가된 주소에서 하위디렉토리 접근시 로그인창 안뜰때
   settings > version control > subversion 의 network 탭을 선택
  edit network options 을 선택
  user과 password를 입력 ok 클릭
 

2016년 5월 17일 화요일

android adb 시스템 기본정보: 하드웨어, 커널 등

cat /proc/version : 커널 버전 
cat /proc/cpuinfo : 프로세서 정보, CPU타입, 모델 제조사 등 
cat /porc/meminfo : 메모리 정보, 실제 메모리 및 가상 메모리 
cat /proc/devices : 현재 커널에 설정되어 있는 장치 목록 
mount : 마운트된 모든 장치 정보 
df : 하드디스크 사용량 
cat /porc/filesystems : 커널에 설정되어 있는 파일시스템 목록 
cat /proc/swaps : 스왑 파티션의 크기와 사용량 
cat /proc/interrupts : 장치가 사용중인 인터럽트(IRQ)목록 표시 
cat /proc/ioports : 현재 사용중인 input/output 포트 
cat /proc/partitions : 파티션 정보 
cat /proc/uptime : 시스템이 얼마나 살아있었는지 
cat /proc/stat : 시스템 상태에 관한 다양한 정보, CPU 사용 통계, 부팅이후 page fault 발생 횟수 등 
cat /proc/zoneinfo : ZONEINFO 
dmesg : 시스템 부팅시 나왔던 메시지 
ps : 실행중인 프로세스 정보 
ps -p - t : 프로세스와 쓰레드 목록 
set or printenv : 환경설정값 출력

android adb 시스템 리소스 사용 현황 보기

vmstat : 시스템 리소스 상황 모니터, CPU, I/O, Memory 등 
cat /proc/diskstats : 디스크 utilization과 throughput. 즉 디스크 I/O현황 
top : 시스템 프로세스 상황 모니터링/ 프로세스별 CPU사용량, 메모리와 스왑 사용량 등 
procrank : 프로세스별 메모리 
dumpsys meminfo [PID] : 해당 프로세스 메모리 상세 정보 
cat /proc/[PID]/stat : 해당 프로세스에 대한 정보, 시작시간, 상태, CPU 사용량 등 
cat /proc/[PID]/maps : 해당 프로세스의 메모리 맵 정보 
cat /proc/vmstat : 버추얼 메모리 통계? 
librank : 라이브러리별 메모리 사용량?

android adb 네트워크 관련

cat /proc/net/netlink : 네트워크 정보 
netcfg : 네트워크 인터페이스와 IP주소 목록 
netstat : 네트워크 연결상태 확인 
nc : 네트워크용 cat 명령어(netcat) 
ifconfig : 네트워크 인터페이스 설정 정보. 장치명을 파라미터로 받음. ip 주소. 서브넷마스크 등 
tcpdump : 실시간 패킷 모니터링 
iftop : 네트워크를 위한 top 
route : 해당 호스트까지 연결하는 중간 경로 정보인 라우팅 테이블 표시 
ping : 원격 호스트와의 연결 테스트 
cat /proc/net/route : Route

android adb 안드로이드 제공 관련

logcat : 로그캣 보기 
pm : package manager의 약자. 패키지/permission/instrumentation/feature 목록, 패키지 설치/제거 등 
am : activity manager의 약자, 액티비티 시작, Intent 브로드캐스팅, Instrumentation 시작, profiling 시작 / 중지 등 
service : 안드로이드 서비스 목록 표시, 서비스에 명령 전달 
monkey : 애플리케이션에 랜덤 이벤트 발생시킴. 사용자 이벤트, 시스템 이벤트의 무작위 발행 
cat /data/anr/traces.txt : VM TRACES (쓰레드 덤프) 
cat /proc/binder/proc/[PID] : 바인더 프로세스 상태 
cat /proc/binder/xxx : 바인더 관련 정보(xxx은 transaction, transaction_log, failed_transaction_log, stats 등) 
cat /data/system/packages.xml : 설치된 패키지 세팅 정보 
setprop : system property 셋팅 
getprop : 셋팅된 system property 목록 출력

android adb 종합 리포트

dumpsys [service] : app/service 상태정보 덤프, 서비스별로 추가 파라미터 받을 수 있음 
dumpstate : device 상태정보 덤프. 상태정보를 추출하는 여러 명령어들의 조합으로 구성 
dumpcrash : 애플리케이션이 crach될 때의 상태정보 덤프 
bugreport : logcat + dumpsys + dumpstat 

--------------------------------------------------------------------------------------------- 
ADB Shell Command - 15가지 팁 

Basic Android Terminal and ADB Shell Command List 
1. How to open a cmd in Android Phone 
  Method 1: “Start” ? “”Program”-” “Accessories” ? “” Command Prompt ” 
  Method 2: “Start” ? “” Run “, type cmd ENTER 
  
2. How to restart Android Phone 
  When the phone and Computer is connected to the data cable, you can enter the following command 
  adb shell reboot === ENTER 
  
3. Restart Android into Recovery Mode 
  With the data cable connected to your phone and computer, enter the following command 

  adb shell reboot recovery === ENTER 
  
4. Convert back to ext2 partition 
  Restart the phone into Recovery mode, press “Alt + X” into the console. Open cmd and enter the following command 

  adb shell === ENTER    
  tune2fs-O ^ has_journal / dev/block/mmcblk0p2 === carriage return 
  e2fsck / dev/block/mmcblk0p2 === carriage return (optional, can be a problem area in section 2, when used) 
  
5. Pulling applications from Android phone to computer 
  adb pull /system/sd/app app  
  adb pull /system/sd/app-private app-private 
  
6. Pushing applications back to android phone from the computer 
  adb push app /system/sd/app    
  adb push app-private /system/sd/app-private 
  
7. Delete existing apps on Android SD 
  adb shell rm -r /system/sd/app  
  adb shell rm -r /system/sd/app-private 
  
8. Repair gravity System or switch to screen 
  Sometimes frequent brushing of phone can cause gravity system or switch to screen failure. Just follow the steps below- 
  Restart the phone into Recovery mode, press “Alt + X” into the console 
  Open cmd and enter the following command 
  mount / data === carriage return  
  rm / data / misc / akmd * / data / misc / rild * === ENTER 
  
9. Ext2/ext3/ext4 formatted partition 
  Enter the following command in the cmd 
  adb remount === ENTER    
  adb shell === ENTER  
  rm-r / system / sd / * === carriage return 
  
10. Remove/ system / app under the application 
  Under normal circumstances / system / app is not under an application. Use the following methods to remove these applications. 
  Open cmd and enter the following command 
  
  adb remount === ENTER    
  adb rm / system / app / Stocks.apk === Enter 
  
11. If the start Time is too Long 
  Just enter the following command in order to view the boot process. 
  adb logcat === ENTER 
  
12. Through Terminal Partition SD card 
  It will erase everything on your SD card 
  $  su  
  # cd /data  
  # wget http://64.105.21.209/bin/lib/droid/sdsplit  
  # chmod 555 sdsplit  
  # /data/sdsplit -fs *size* (add -nc to the end for JFv1.5ADP) 
  
13. From the Recovery Screen, send an update file to your SD card. 
  adb shell mount /sdcard  
  adb shell rm /sdcard/update.zip  
  adb push *filename* /sdcard/update.zip 
  
14. Restoring a nandroid backup via Fastboot 
  Start command-prompt/terminal cd to the nandroid folder and enter following commands 
  fastboot erase boot  
  fastboot erase recovery  
  fastboot flash system system.img  
  fastboot flash boot boot.img  
  fastboot flash userdata data.img  
  fastboot flash recovery recovery.img  
  fastboot reboot 
  
15. Clear Search History in Android 
  Search History is accounted for Mobile Memory. It can also leak your privacy information as well. Just follow the steps below to clear android history.  
  Steps are as follows: 
  1. Make sure your mobile phone has Root authority. 
  2. Open the super-terminal. 
  3. Enter the following command 
    su 
    rm / data / data / com.android.vending / databases / suggestions.db 
  4. Exit Hyper Terminal and restart the phone. 

--------------------------------------------------------------------------------------------- 

adb devices 

adb 서버가 인식한 휴대폰과 에뮬레이터 목록을 보여준다. 
연결된 devices의 TCP/IP 포트 번호를 알아낼 때 도움이 된다. 

다른 명령어를 사용할 때, -s나 -e 옵션은 여러 개의 장치를 연결했을 때 특정한 디바이스를 지정할 때 사용한다. 

예) 
디바이스 검색 
adb devices 
  
adb shell 

타겟 시스템의 쉘에 연결하고 # 프롬프트를 띄운다. 쉘은 간소한 유닉스 쉘 같아서 간단한 명령으로 타겟 시스템을 탐색하고 수정할 수 있다. 

예) 
여러 단말기 중에 하나를 선택해서 접속할 때, 
adb -s emulator-5554 shell 
  
adb install [-l][-r] file_spec 

app을 설치하거나 재설치할 때 사용한다. 
-l : 다른 장치로 복사돼 넘어가는 것을 막는다. 
-r: 이미 존재하는 app 데이터를 지우지 않은 채 어플리케이션을 재설치 한다. 
file_spec: 설치할 app의 .apk 파일 

예) 
파일 설치시 
adb install c:\download\HangulKeyboard.apk 
  
adb uninstall [-k] package 

패키지 이름을 가진 app을 제거하다. 
-k : app의 데이터를 보존한다. 
package: 패키지의 전체 경로, .apk 확장자는 빼야 한다. 

예) 
패키지 삭제시 
adb uninstall com.falinux.android.hello 
  
adb push local remote 

개발자 컴퓨터에 있는 local이란 이름을 가진 파일을 타겟 시스템에 remote란 이름으로 복사한다. 

예) 
com.falinux.android.rose.apk 파일을 안드로이드 기기 /data/app/ 폴더 안으로 집어넣을 때, 
adb push c:\com.falinux.android.rose.apk /data/app/ 
  
adb pull remote local 

타겟 시스템에 있는 remote라는 파일을 개발자 컴퓨터에 local이란 이름으로 복사한다. 

예) 
안드로이드 기기 /data/app/com.falinux.android.rose.apk 파일을 C 드라이브로 가져올 때, 
adb pull /data/app/com.falinux.android.rose.apk c:\com.falinux.android.rose.apk 
  
adb reboot 

안드로이드 시스템을 리부팅 시킨다. 
  
adb kill-server 

adb 에 문제가 있을 경우, adb를 종료시킨다. 
  
adb start-server 

종료된 adb를 실행 시킨다.

android studio intellij Memory Heap 설정

androidStudio > 
32 bit : “설치경로/bin/studio.exe.vmoptions” 
64 bit : “설치경로/bin/studio64.exe.vmoptions” 

intellij > 
32 bit : “설치경로/bin/idea.exe.vmoptions” 
64 bit : “설치경로/bin/idea64.exe.vmoptions”

android studio 선택된 변수 배경 색상 바꾸기

Setting에서 
Editor -> Colors & Fonts -> General 
Identifier under caret 와 
Identifier under caret(write) 의 background 색상 변경

android adb system app 삭제

adb shell rm /system/app/MyApp* 
adb uninstall org.my.app

android ViewFlipper 를 사용한 include 변경

==== xml 파일 ========= 
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/vf" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <include android:id="@+id/include1" layout="@layout/one_layout" /> 
    <include android:id="@+id/include2" layout="@layout/two_layout" /> 

</ViewFlipper> 
======================== 

==== java 파일 ==== 

ViewFlipper vf = (ViewFlipper)findViewById(R.id.vf); 
For Button onClickListener: 

button.setOnClickListener(new View.OnClickListener() { 

            @Override 
            public void onClick(View v) { 
                // TODO Auto-generated method stub 
                vf.setDisplayedChild(1);   // id가 include2  보여주기         
            } 
});

android TextView style 변경 방법

textViewChannelNumber.setTextAppearance(mContext, R.style.sky_W2);

android RecyclerView에서 scroll 표시

<android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="vertical" />

android R.string 의 동적 id 값으로 얻어 내기

String str = getName("Network", getActivity().getResources(), getActivity().getPackageName()); 

    private static String getName(final String attribute, final Resources res, final String packageName) { 
        // dynamically search for a translation of the attribute 
        final int id = res.getIdentifier(attribute, "string", packageName); 
        if (id > 0) { 
            final String translated = res.getString(id); 
//            if (StringUtils.isNotBlank(translated)) 
            { 
                return translated; 
            } 
        } 
        return attribute; 
    }

android R.drawable의 동적 id 값으로 리소스Resource 이미지 얻어 내기

String image_pre = "rating"; 
String rating = image_pre + "_15"; 
int lid = getActivity().getResources().getIdentifier(rating, "drawable", getActivity().getPackageName());

android 강제 키 이벤트, 클릭 이벤트 발생 시키기

// 키 이벤트 발생 
KeyEvent evt = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT); 
                new Instrumentation().sendKeySync(evt); 

// application 에서  Instrumentation 사용시 문제 발생 됨. 아래처럼 새로운 Thread 생성하여 처리해야됨. 
            new Thread(() -> { 
                new Instrumentation().sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT)); 
            }).start(); 

============================================= 
Button bt_parse = (Button)findViewById(R.id.bt_parse);
        bt_parse.performClick(); // 클릭 이벤트 발생 
        bt_parse.performLongClick(); // 롱클릭 이벤트 발생

// 강제 키 down 이벤트 발생 
 new Thread(() -> { 
                new Instrumentation().sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN)); 
            }).start();

android xml로 버튼클릭 포커스 제스쳐, 상태에 따른 버튼이미지 변경

버튼의 상태 
 default  아무것도 아닌 상태 
 pressed    누르고 있는 상태 
 focused  누르고 있진 않았지만 포커스가 주어진 상태 
 selected    누른 상태 

============== button_change.xml 내용 ================== 
<?xml version="1.0" encoding="UTF-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_pressed="true" android:drawable="@drawable/btn_press" /> <!-- pressed --> 
    <item android:state_selected="true" android:drawable="@drawable/btn_select" /> <!-- selected --> 
    <item android:drawable="@drawable/btn_default" /> <!-- default --> 
</selector> 

============== 사용 ================ 
<ImageButton 
    android:id="@+id/main_btn_change" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/button_change" 
/>

android key event 의 값을 string 로 표시

event.getUnicodeChar(); 


            public boolean onKey(View v, int keyCode, KeyEvent event) { 
            if(KeyEvent.ACTION_DOWN == event.getAction()){ 
            char keyDown = (char)event.getUnicodeChar(); //키보드에서 입력받은 값 
            } 
                return false; 
            }

java char 을 string 로 string 을 char 로 변환

==================== 
char --> string 
==================== 
// 단어가 하나일때 
String change = ""; 
char cr = 'A'; 
change = String.valueOf(cr); 
change = Character.toString(cr); 
change = new Character(cr).toString(); 
          
System.out.println(change); 

==================== 
 String 객체를 생성할 때 생성자 함수중 char 를 String 으로 변경해 줄수 있는 것 
==================== 

String str = "한글데이터 변환하기"; 
char[] chr = str.toCharArray(); 
String change = ""; 
  
// String 클래스 이용 
change = new String(chr, 0, chr.length); 
  
System.out.println(change); 


==================== 
string 클래스에는 문자열을 char 배열로 변환 
==================== 
String str = "한글데이터 변환하기"; 
char[] chr = str.toCharArray(); 
String change = ""; 
  
// 하나씩 더하는 방법 
for (int i = 0; i < chr.length; i++) { 
    change += Character.toString(chr[i]); 

  
System.out.println(change);

android am 옵션, 쉘에서 액티비티나 서비스를 실행하는 방법

[Usage] 
- am start -a android.intent.action.MAIN -n 패키지명/액티비티 경로명 
- am startservice -n 패키지명/서비스경로명 
- adb shell am broadcast -a "브로드캐스트명" 
  
쉘에서 액티비티나 서비스를 실행하는 방법입니다. 
쉘의 AM 명령어를 사용합니다. 
  
1. 액티비스 실행하는 방법 
*명령어 
adb shell am start -a android.intent.action.MAIN -n 패키지명/액티비티 경로명 
  
예) 
am start -a android.intent.action.MAIN -n com.example.echo/com.example.echo.echodemo 
  
  
2. 서비스 실행하는 방법 
*명령어 
adb shell am startservice -n 패키지명/서비스경로명 
  
예) 
am startservice -n com.example.echo/com.example.echo.echoservice 
3. broadcast 테스트하기 
*명령어 
 adb shell am broadcast -a "브로드캐스트명" 
  
ex) 
adb shell am broadcast -a android.accounts.LOGIN_ACCOUNTS_CHANGED 

=============================================== 

자주쓰는 am 옵션 


- device 인식이 잘 안될때 케이블을 꼽았다 꼽거나 adb server를 죽입니다. 
adb kill-server 

- 연결되있는 devices 리스트를 볼수있습니다. 
adb devices 

- 여러개의 device를 연결했을 경우 선택해서 사용할 수 있습니다. 
adb -d logcat (device) 
adb -e logcat (emulator) 
adb -s emulator-xxx logcat (device serial) 

- 쉘 
adb -d shell 

- apk 설치 
adb -d install test.apk 
adb -d shell 
# pm install /sdcard/test.apk 

- 재설치 
adb -d install -r test.apk 

- 사인 문제로 재설치 안될 경우 오버라이트로 설치 
adb -d push test.apk /system/app 

- 텍스트 입력입니다. 주로 터치키보드로 긴 URL이나 긴 비밀번호 입력하기 힘들때 사용합니다. 
adb shell input text "삼천궁녀" 

- 디버깅 용도로 아주 가끔 사용합니다. 랜덤 이벤트로 테스트합니다. 
adb shell monkey -v 1000 com.test.app1 

- 특정 액티비티를 실행합니다. 
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings 


페이스북 앱 실행 
am start -a android.intent.action.VIEW -d facebook://facebook.com/inbox  

sd카드 
am start -a android.intent.action.VIEW -d file:///sdcard/me.vcard -t text/x-vcard  

갤러리 실행 
am start -a android.intent.action.GET_CONTENT -t image/jpeg  

카메라 실행 
am start -a android.media.action.IMAGE_CAPTURE 

환경설정 실행 
am start -a android.intent.action.MAIN -n com.android.settings/.Settings 

브라우저로 구글띄우기 
am start -a android.intent.action.VIEW http://www.google.com 

전화걸기 다이얼 입력 
am start -a android.intent.action.DIAL tel:010XXXXXXX 

전화걸기 
am start -a android.intent.action.CALL tel:010XXXXXXX 

전화걸기 


am start -a android.intent.action.DAIL -d tel:010-XXXX-XXXX 

문자전송 
am start -a android.intent.action.SENDTO -d sms:"010XXXXXXXX" --es sms_body "test message!!" --ez exit_on_sent true 
============================== 
미결 
$ adb shell input keyevent 22 
$ adb shell input keyevent 6 
============================== 

패턴? 
am start -n com.android.settings/com.android.settings.ChooseLockGeneric --ez confirm_credentials false --ei lockscreen.password_type 0 --activity-clear-task 

GPS 
am start -a android.intent.action.VIEW geo:37.111111-222.333333 


달력실행 
am start -n com.android.calendar/com.android.calendar.LaunchActivity