시간 바꾸기 (24시로)

date -s 12:34:56



날짜 바꾸기

date -s '"2016-03-25 12:34:56"



타임존 변경

[root@kserver112-222 /]# date

2016. 03. 25. (금) 17:52:19 KST



만약  KST가 아닌 경우(UTC)  서울 기준으로 맞춰 주어야 한다.

/etc/localtime 에 심볼링크를 거는 방법도 있지만 여기서는

tzselect 를 이용하자. Asia를 선택하고 (5번) 다음으로 Korea(South) (23번)선택.



[root@kserver112-222 /]# tzselect

Please identify a location so that time zone rules can be set correctly.

Please select a continent or ocean.

 1) Africa

 2) Americas

 3) Antarctica

 4) Arctic Ocean

 5) Asia

 6) Atlantic Ocean

 7) Australia

 8) Europe

 9) Indian Ocean

10) Pacific Ocean

11) none - I want to specify the time zone using the Posix TZ format.

#? 5

Please select a country.

 1) Afghanistan           18) Israel                35) Palestine

 2) Armenia               19) Japan                 36) Philippines

 3) Azerbaijan            20) Jordan                37) Qatar

 4) Bahrain               21) Kazakhstan            38) Russia

 5) Bangladesh            22) Korea (North)         39) Saudi Arabia

 6) Bhutan                23) Korea (South)         40) Singapore

 7) Brunei                24) Kuwait                41) Sri Lanka

 8) Cambodia              25) Kyrgyzstan            42) Syria

 9) China                 26) Laos                  43) Taiwan

10) Cyprus                27) Lebanon               44) Tajikistan

11) East Timor            28) Macau                 45) Thailand

12) Georgia               29) Malaysia              46) Turkmenistan

13) Hong Kong             30) Mongolia              47) United Arab Emirates

14) India                 31) Myanmar (Burma)       48) Uzbekistan

15) Indonesia             32) Nepal                 49) Vietnam

16) Iran                  33) Oman                  50) Yemen

17) Iraq                  34) Pakistan

#? 23


The following information has been given:


        Korea (South)


Therefore TZ='Asia/Seoul' will be used.

Local time is now:      Fri Mar 25 17:54:33 KST 2016.

Universal Time is now:  Fri Mar 25 08:54:33 UTC 2016.

Is the above information OK?

1) Yes

2) No

#? 1


You can make this change permanent for yourself by appending the line

        TZ='Asia/Seoul'; export TZ

to the file '.profile' in your home directory; then log out and log in again.


Here is that TZ value again, this time on standard output so that you

can use the /usr/bin/tzselect command in shell scripts:

Asia/Seoul

[root@kserver112-222 /]# date

2016. 03. 25. (금) 17:54:47 KST



'Server' 카테고리의 다른 글

linux 명령어 간단 정리 1  (0) 2021.01.09
[Linux] 톰캣 재시작 스크립트  (0) 2020.08.11
[Linux/Centos] 버전 확인 및 비트 확인  (0) 2016.11.10
[Linux/Centos] 용량 확인  (0) 2016.11.10
[Linux/Centos] Crontab 사용법 정리  (0) 2016.11.10














error_reporting(E_ALL);

ini_set("display_errors", 1);










기본적으로 WebView는 onClickListener가 먹지 않는다. 그러므로 onTouchListener를 달아줘야 하는데 onTouchListener는 ACTION_DOWN, ACTION_MOVE, ACTION_UP을 구현해줘야 한다.







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
public class MainActivity extends Activity implements View.OnTouchListener{
 
    // 클릭으로 볼 최대시간        
    private static final int MAX_CLICK_DURATION = 1000;
    // 클릭으로 볼 최대거리 dp        
    private static final int MAX_CLICK_DISTANCE = 15;
 
    private long pressStartTime;
    private float pressedX;
    private float pressedY;
    private boolean stayedWithinClickDistance;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        findViewById(R.id.webview).setOnTouchListener(this);
    }
 
 
 
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                pressStartTime = System.currentTimeMillis();
                pressedX = motionEvent.getX();
                pressedY = motionEvent.getY();
                stayedWithinClickDistance = true;
                break;
            }
            case MotionEvent.ACTION_MOVE: {
                if (stayedWithinClickDistance && distance(pressedX, pressedY, motionEvent.getX(), motionEvent.getY()) > MAX_CLICK_DISTANCE) {
                    stayedWithinClickDistance = false;
                }
                break;
            }
            case MotionEvent.ACTION_UP: {
                long pressDuration = System.currentTimeMillis() - pressStartTime;
                if (pressDuration < MAX_CLICK_DURATION && stayedWithinClickDistance) {
                    // 클릭처리
                }
            }
        }
        return false;
    }
 
}
cs






Java에서 Map 관련하여 반복문을 사용하는 경우가 여러가지가 있다. 가장 많이 쓰이는 몇가지를 살펴보고 장단점을 알아보도록한다. Java의 모든 map들은 Map interface를 사용하므로 다음 경우들은 모든 map에 대하여 사용 가능하다.

예 : HashMap, TreeMap, LinkedMap, Hashtable 등등.. 




1. Entry 에 For-Each Loop 사용

  가장 일반적이고 거의 모든 경우에 사용된다. 반복문 안에 key값과 value값이 전부 필요할때 사용한다.


1
2
3
4
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
cs


  참고 : For-Each Loop는 Java 5이상에서 사용가능하다. 또한 NullPointerExecption을 발생 시킬 수 있으므로 null 체크를 하도록 하자.




2. Key Value 에 For-Each Loop사용

  entry 대신 key값이나 value 값만 필요할 때 사용한다.


1
2
3
4
5
6
7
8
9
10
11
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
 
//iterating over keys only
for (Integer key : map.keySet()) {
    System.out.println("Key = " + key);
}
 
//iterating over values only
for (Integer value : map.values()) {
    System.out.println("Value = " + value);
}
cs


  entrySet을 사용할 때보다 약 10%정도 빠르다.




3. Iterator 사용


- Generic 사용


1
2
3
4
5
6
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Iterator<Map.Entry<Integer, Integer>> entries = map.entrySet().iterator();
while (entries.hasNext()) {
    Map.Entry<Integer, Integer> entry = entries.next();
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
cs



- Generic 미사용


1
2
3
4
5
6
7
8
Map map = new HashMap();
Iterator entries = map.entrySet().iterator();
while (entries.hasNext()) {
    Map.Entry entry = (Map.Entry) entries.next();
    Integer key = (Integer)entry.getKey();
    Integer value = (Integer)entry.getValue();
    System.out.println("Key = " + key + ", Value = " + value);
}
cs

 

 keySet이나 values 에도 똑같이 적용가능하다. 이 방법은 오래된 방법이지만 Java 버전이 낮은 경우에 유일하게 사용가능한 방법이다. 또 한가지 중요한 장점은 반복문을 사용하는 도중에 iterator.remove()를 통해 항목들을 삭제할 수 있는 유일한 방법이다. 만약 삭제 작업을 For-Each 구문에서 사용한다면 "unpredictable results"를 얻게된다(javadoc, Map은 순서를 보장하지 않기 때문에). 성능 측면에서 For-Each와 비슷하다.





4. Key값으로 Value를 찾는 반복문


  코드상으로는 간단해 보이지만 1번 방법에 비해 비효율적이고 성능면에서 안좋은 방법이다. key값을 이용해서 value를 찾는 과정에서 시간이 많이 소모된다.(1번 방법보다 약 20%~200% 성능저하가 있음)


1
2
3
4
5
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Integer key : map.keySet()) {
    Integer value = map.get(key);
    System.out.println("Key = " + key + ", Value = " + value);
}
cs



'Java' 카테고리의 다른 글

Arrays.asList는 동적 List가 아니다.  (0) 2020.06.19
[Java] Wrapper 클래스 Cache  (0) 2020.06.18

버전확인


1. cat /etc/*release*

[root@kserver112-222 ~]# cat /etc/*release*

cat: /etc/lsb-release.d: 디렉토리입니다

CentOS release 5.11 (Final)


2. cat /proc/version

리눅스  커널 버전 확인

[root@kserver112-222 ~]# cat /proc/version

Linux version 2.6.18-400.1.1.el5 (mockbuild@builder17.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)) #1 SMP Thu Dec 18 00:58:32 EST 2014






비트확인(32bit / 64bit)


1. getconf 

[root@kserver112-222 ~]# getconf LONG_BIT

32

-> 32 비트


[root@kserver112-222 ~]# getconf LONG_BIT

64

-> 63비트


2. arch

[root@kserver112-222 ~]# arch

x86_64

-> 64비트


[root@kserver112-222 ~]# arch

i686

-> 32비트 (i386도있음)




  

AlertDialog를 생성하고 positive button 이나 negative button 을 등록 시 버튼을 클릭하게 되면 안드로이드에서는 자동으로 dismiss를 호출하게 된다.

하지만 조건에 맞지 않는 경우 창을 닫을것이 아니라 사용자에게 알려 AlertDialog를 닫지 않고 입력창을 유지해야 하는 경우가 있다.  





1. AlertDialog.Builder - show 후에 기본 버튼 변경


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("Test for preventing dialog close");
builder.setPositiveButton("Test"
        new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                //Do nothing here because we override this button later to change the close behaviour. 
                //However, we still need this because on older versions of Android unless we 
                //pass a handler the button doesn't get instantiated
            }
        });
AlertDialog dialog = builder.create();
dialog.show();
//Overriding the handler immediately after show is probably a better approach than OnShowListener as described below
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener()
      {            
          @Override
          public void onClick(View v)
          {
              Boolean wantToCloseDialog = false;
              //Do stuff, possibly set wantToCloseDialog to true then...
              if(wantToCloseDialog)
                  dialog.dismiss();
              //else dialog stays open. Make sure you have an obvious way to close the dialog especially if you set cancellable to false.
          }
      });
cs





2. DialogFragment override onStart() 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage("Test for preventing dialog close");
    builder.setPositiveButton("Test"
        new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                //Do nothing here because we override this button later to change the close behaviour. 
                //However, we still need this because on older versions of Android unless we 
                //pass a handler the button doesn't get instantiated
            }
        });
    return builder.create();
}
 
@Override
public void onStart()
{
    super.onStart();    //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point
    final AlertDialog d = (AlertDialog)getDialog();
    if(d != null)
    {
        Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View v)
                    {
                        Boolean wantToCloseDialog = false;
                        //Do stuff, possibly set wantToCloseDialog to true then...
                        if(wantToCloseDialog)
                            d.dismiss();
                        //else dialog stays open. Make sure you have an obvious way to close the dialog especially if you set cancellable to false.
                    }
                });
    }
}
cs





3. DialogPreference - override showDialog()


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@Override
protected void onPrepareDialogBuilder(Builder builder)
{
    super.onPrepareDialogBuilder(builder);
    builder.setPositiveButton("Test"this);   //Set the button here so it gets created
}
 
@Override
protected void showDialog(Bundle state)
{       
    super.showDialog(state);    //Call show on default first so we can override the handlers
 
    final AlertDialog d = (AlertDialog) getDialog();
    d.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener()
            {            
                @Override
                public void onClick(View v)
                {
                    Boolean wantToCloseDialog = false;
                    //Do stuff, possibly set wantToCloseDialog to true then...
                    if(wantToCloseDialog)
                        d.dismiss();
                    //else dialog stays open. Make sure you have an obvious way to close the dialog especially if you set cancellable to false.
                }
            });
}
cs









안드로이드 Material Design에서 샘플로 나온 컬러를 hex값으로 변환한것


colors.xml에 지정해놓고 쓰자.



    <!-- Grey -->

    <color name="grey_50">#FAFAFA</color>

    <color name="grey_100">#F5F5F5</color>

    <color name="grey_200">#EEEEEE</color>

    <color name="grey_300">#E0E0E0</color>

    <color name="grey_400">#BDBDBD</color>

    <color name="grey_500">#9E9E9E</color>

    <color name="grey_600">#757575</color>

    <color name="grey_700">#616161</color>

    <color name="grey_800">#424242</color>

    <color name="grey_900">#212121</color>

    <!-- Grey -->


    <!-- Red -->

    <color name="red_50">#FFEBEE</color>

    <color name="red_100">#FFCDD2</color>

    <color name="red_200">#EF9A9A</color>

    <color name="red_300">#E57373</color>

    <color name="red_400">#EF5350</color>

    <color name="red_500">#F44336</color>

    <color name="red_600">#E53935</color>

    <color name="red_700">#D32F2F</color>

    <color name="red_800">#C62828</color>

    <color name="red_900">#B71C1C</color>

    <color name="red_A100">#FF8A80</color>

    <color name="red_A200">#FF5252</color>

    <color name="red_A400">#FF1744</color>

    <color name="red_A700">#D50000</color>

    <!-- Red -->


    <!-- Pink -->

    <color name="pink_50">#FCE4EC</color>

    <color name="pink_100">#F8BBD0</color>

    <color name="pink_200">#F48FB1</color>

    <color name="pink_300">#F06292</color>

    <color name="pink_400">#EC407A</color>

    <color name="pink_500">#E91E63</color>

    <color name="pink_600">#D81B60</color>

    <color name="pink_700">#C2185B</color>

    <color name="pink_800">#AD1457</color>

    <color name="pink_900">#880E4F</color>

    <color name="pink_A100">#FF80AB</color>

    <color name="pink_A200">#FF4081</color>

    <color name="pink_A400">#F50057</color>

    <color name="pink_A700">#C51162</color>

    <!-- Pink -->


    <!-- Purple -->

    <color name="purple_50">#F3E5F5</color>

    <color name="purple_100">#E1BEE7</color>

    <color name="purple_200">#CE93D8</color>

    <color name="purple_300">#BA68C8</color>

    <color name="purple_400">#AB47BC</color>

    <color name="purple_500">#9C27B0</color>

    <color name="purple_600">#8E24AA</color>

    <color name="purple_700">#7B1FA2</color>

    <color name="purple_800">#6A1B9A</color>

    <color name="purple_900">#4A148C</color>

    <color name="purple_A100">#EA80FC</color>

    <color name="purple_A200">#E040FB</color>

    <color name="purple_A400">#D500F9</color>

    <color name="purple_A700">#AA00FF</color>

    <!-- Purple -->


    <!-- Deep Purple -->

    <color name="dark_purple_50">#EDE7F6</color>

    <color name="dark_purple_100">#D1C4E9</color>

    <color name="dark_purple_200">#B39DDB</color>

    <color name="dark_purple_300">#9575CD</color>

    <color name="dark_purple_400">#7E57C2</color>

    <color name="dark_purple_500">#673AB7</color>

    <color name="dark_purple_600">#5E35B1</color>

    <color name="dark_purple_700">#512DA8</color>

    <color name="dark_purple_800">#4527A0</color>

    <color name="dark_purple_900">#311B92</color>

    <color name="dark_purple_A100">#B388FF</color>

    <color name="dark_purple_A200">#7C4DFF</color>

    <color name="dark_purple_A400">#651FFF</color>

    <color name="dark_purple_A700">#6200EA</color>

    <!-- Deep Purple -->


    <!-- Indigo -->

    <color name="indigo_50">#E8EAF6</color>

    <color name="indigo_100">#C5CAE9</color>

    <color name="indigo_200">#9FA8DA</color>

    <color name="indigo_300">#7986CB</color>

    <color name="indigo_400">#5C6BC0</color>

    <color name="indigo_500">#3F51B5</color>

    <color name="indigo_600">#3949AB</color>

    <color name="indigo_700">#303F9F</color>

    <color name="indigo_800">#283593</color>

    <color name="indigo_900">#1A237E</color>

    <color name="indigo_A100">#8C9EFF</color>

    <color name="indigo_A200">#536DFE</color>

    <color name="indigo_A400">#3D5AFE</color>

    <color name="indigo_A700">#304FFE</color>

    <!-- Indigo -->


    <!-- Blue -->

    <color name="blue_50">#E3F2FD</color>

    <color name="blue_100">#BBDEFB</color>

    <color name="blue_200">#90CAF9</color>

    <color name="blue_300">#64B5F6</color>

    <color name="blue_400">#42A5F5</color>

    <color name="blue_500">#2196F3</color>

    <color name="blue_600">#1E88E5</color>

    <color name="blue_700">#1976D2</color>

    <color name="blue_800">#1565C0</color>

    <color name="blue_900">#0D47A1</color>

    <color name="blue_A100">#82B1FF</color>

    <color name="blue_A200">#448AFF</color>

    <color name="blue_A400">#2979FF</color>

    <color name="blue_A700">#2962FF</color>

    <!-- Blue -->


    <!-- Light Blue -->

    <color name="light_blue_50">#E1F5FE</color>

    <color name="light_blue_100">#B3E5FC</color>

    <color name="light_blue_200">#81D4FA</color>

    <color name="light_blue_300">#4FC3F7</color>

    <color name="light_blue_400">#29B6F6</color>

    <color name="light_blue_500">#03A9F4</color>

    <color name="light_blue_600">#039BE5</color>

    <color name="light_blue_700">#0288D1</color>

    <color name="light_blue_800">#0277BD</color>

    <color name="light_blue_900">#01579B</color>

    <color name="light_blue_A100">#80D8FF</color>

    <color name="light_blue_A200">#40C4FF</color>

    <color name="light_blue_A400">#00B0FF</color>

    <color name="light_blue_A700">#0091EA</color>

    <!-- Light Blue -->


    <!-- Cyan -->

    <color name="cyan_50">#E0F7FA</color>

    <color name="cyan_100">#B2EBF2</color>

    <color name="cyan_200">#80DEEA</color>

    <color name="cyan_300">#4DD0E1</color>

    <color name="cyan_400">#26C6DA</color>

    <color name="cyan_500">#00BCD4</color>

    <color name="cyan_600">#00ACC1</color>

    <color name="cyan_700">#0097A7</color>

    <color name="cyan_800">#00838F</color>

    <color name="cyan_900">#006064</color>

    <color name="cyan_A100">#84FFFF</color>

    <color name="cyan_A200">#18FFFF</color>

    <color name="cyan_A400">#00E5FF</color>

    <color name="cyan_A700">#00B8D4</color>

    <!-- Cyan -->


    <!-- Teal -->

    <color name="teal_50">#E0F2F1</color>

    <color name="teal_100">#B2DFDB</color>

    <color name="teal_200">#80CBC4</color>

    <color name="teal_300">#4DB6AC</color>

    <color name="teal_400">#26A69A</color>

    <color name="teal_500">#009688</color>

    <color name="teal_600">#00897B</color>

    <color name="teal_700">#00796B</color>

    <color name="teal_800">#00695C</color>

    <color name="teal_900">#004D40</color>

    <color name="teal_A100">#A7FFEB</color>

    <color name="teal_A200">#64FFDA</color>

    <color name="teal_A400">#1DE9B6</color>

    <color name="teal_A700">#00BFA5</color>

    <!-- Teal -->


    <!-- Green -->

    <color name="green_50">#E8F5E9</color>

    <color name="green_100">#C8E6C9</color>

    <color name="green_200">#A5D6A7</color>

    <color name="green_300">#81C784</color>

    <color name="green_400">#66BB6A</color>

    <color name="green_500">#4CAF50</color>

    <color name="green_600">#43A047</color>

    <color name="green_700">#388E3C</color>

    <color name="green_800">#2E7D32</color>

    <color name="green_900">#1B5E20</color>

    <color name="green_A100">#B9F6CA</color>

    <color name="green_A200">#69F0AE</color>

    <color name="green_A400">#00E676</color>

    <color name="green_A700">#00C853</color>

    <!-- Green -->


    <!-- Light Green -->

    <color name="light_green_50">#F1F8E9</color>

    <color name="light_green_100">#DCEDC8</color>

    <color name="light_green_200">#C5E1A5</color>

    <color name="light_green_300">#AED581</color>

    <color name="light_green_400">#9CCC65</color>

    <color name="light_green_500">#8BC34A</color>

    <color name="light_green_600">#7CB342</color>

    <color name="light_green_700">#689F38</color>

    <color name="light_green_800">#558B2F</color>

    <color name="light_green_900">#33691E</color>

    <color name="light_green_A100">#CCFF90</color>

    <color name="light_green_A200">#B2FF59</color>

    <color name="light_green_A400">#76FF03</color>

    <color name="light_green_A700">#64DD17</color>

    <!-- Light Green -->


    <!-- Lime -->

    <color name="lime_50">#F9FBE7</color>

    <color name="lime_100">#F0F4C3</color>

    <color name="lime_200">#E6EE9C</color>

    <color name="lime_300">#DCE775</color>

    <color name="lime_400">#D4E157</color>

    <color name="lime_500">#CDDC39</color>

    <color name="lime_600">#C0CA33</color>

    <color name="lime_700">#AFB42B</color>

    <color name="lime_800">#9E9D24</color>

    <color name="lime_900">#827717</color>

    <color name="lime_A100">#F4FF81</color>

    <color name="lime_A200">#EEFF41</color>

    <color name="lime_A400">#C6FF00</color>

    <color name="lime_A700">#AEEA00</color>

    <!-- Lime -->


    <!-- Yellow -->

    <color name="yellow_50">#FFFDE7</color>

    <color name="yellow_100">#FFF9C4</color>

    <color name="yellow_200">#FFF59D</color>

    <color name="yellow_300">#FFF176</color>

    <color name="yellow_400">#FFEE58</color>

    <color name="yellow_500">#FFEB3B</color>

    <color name="yellow_600">#FDD835</color>

    <color name="yellow_700">#FBC02D</color>

    <color name="yellow_800">#F9A825</color>

    <color name="yellow_900">#F57F17</color>

    <color name="yellow_A100">#FFFF8D</color>

    <color name="yellow_A200">#FFFF00</color>

    <color name="yellow_A400">#FFEA00</color>

    <color name="yellow_A700">#FFD600</color>

    <!-- Yellow -->


    <!-- Amber -->

    <color name="amber_50">#FFF8E1</color>

    <color name="amber_100">#FFECB3</color>

    <color name="amber_200">#FFE082</color>

    <color name="amber_300">#FFD54F</color>

    <color name="amber_400">#FFCA28</color>

    <color name="amber_500">#FFC107</color>

    <color name="amber_600">#FFB300</color>

    <color name="amber_700">#FFA000</color>

    <color name="amber_800">#FF8F00</color>

    <color name="amber_900">#FF6F00</color>

    <color name="amber_A100">#FFE57F</color>

    <color name="amber_A200">#FFD740</color>

    <color name="amber_A400">#FFC400</color>

    <color name="amber_A700">#FFAB00</color>

    <!-- Amber -->


    <!-- Orange -->

    <color name="orange_50">#FFF3E0</color>

    <color name="orange_100">#FFE0B2</color>

    <color name="orange_200">#FFCC80</color>

    <color name="orange_300">#FFB74D</color>

    <color name="orange_400">#FFA726</color>

    <color name="orange_500">#FF9800</color>

    <color name="orange_600">#FB8C00</color>

    <color name="orange_700">#F57C00</color>

    <color name="orange_800">#EF6C00</color>

    <color name="orange_900">#E65100</color>

    <color name="orange_A100">#FFD180</color>

    <color name="orange_A200">#FFAB40</color>

    <color name="orange_A400">#FF9100</color>

    <color name="orange_A700">#FF6D00</color>

    <!-- Orange -->


    <!-- Deep Orange -->

    <color name="deep_orange_50">#FBE9E7</color>

    <color name="deep_orange_100">#FFCCBC</color>

    <color name="deep_orange_200">#FFAB91</color>

    <color name="deep_orange_300">#FF8A65</color>

    <color name="deep_orange_400">#FF7043</color>

    <color name="deep_orange_500">#FF5722</color>

    <color name="deep_orange_600">#F4511E</color>

    <color name="deep_orange_700">#E64A19</color>

    <color name="deep_orange_800">#D84315</color>

    <color name="deep_orange_900">#BF360C</color>

    <color name="deep_orange_A100">#FF9E80</color>

    <color name="deep_orange_A200">#FF6E40</color>

    <color name="deep_orange_A400">#FF3D00</color>

    <color name="deep_orange_A700">#DD2C00</color>

    <!-- Deep Orange -->


    <!-- Brown -->

    <color name="brown_50">#EFEBE9</color>

    <color name="brown_100">#D7CCC8</color>

    <color name="brown_200">#BCAAA4</color>

    <color name="brown_300">#A1887F</color>

    <color name="brown_400">#8D6E63</color>

    <color name="brown_500">#795548</color>

    <color name="brown_600">#6D4C41</color>

    <color name="brown_700">#5D4037</color>

    <color name="brown_800">#4E342E</color>

    <color name="brown_900">#3E2723</color>

    <!-- Brown -->


    <!-- Blue Grey -->

    <color name="blue_grey_50">#ECEFF1</color>

    <color name="blue_grey_100">#CFD8DC</color>

    <color name="blue_grey_200">#B0BEC5</color>

    <color name="blue_grey_300">#90A4AE</color>

    <color name="blue_grey_400">#78909C</color>

    <color name="blue_grey_500">#607D8B</color>

    <color name="blue_grey_600">#546E7A</color>

    <color name="blue_grey_700">#455A64</color>

    <color name="blue_grey_800">#37474F</color>

    <color name="blue_grey_900">#263238</color>

    <!-- Blue Grey -->





Android Studio에서 아무 설정도 하지 않고 APK를 생성하면 release, debug 이런식으로 생성이 되기 때문에 생성후에 다시 이름을 바꿔줘야한다. 


이것은 매우 귀찮은 일이다..


그러므로 build.gradle에서 설정 해주도록 하자.







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
 
android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'
//    lintOptions {
//        checkReleaseBuilds false
//    }
    dexOptions {
        javaMaxHeapSize '2g'
    }
    defaultConfig {
        applicationId 'com.fullstack'
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 113
        versionName "1.1.3"
        multiDexEnabled true
    }
 
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
        }
 
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                def apk = output.outputFile;
                def newName = apk.name.replace(".apk""_" + defaultConfig.versionCode + ".apk");
                output.outputFile = new File(apk.parentFile, newName);
            }
        }
 
    }
}
 
 
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
}
cs



코드는 뭐 이런식으로 되어있을 테고.. 봐야할 부분은 다음이다. buildTypes안에 넣어주면 된다.


1
2
3
4
5
6
7
8
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def apk = output.outputFile;
        def newName = apk.name.replace(".apk""_" + defaultConfig.versionCode + ".apk");
        output.outputFile = new File(apk.parentFile, newName);
    }
}
 
cs

apk.name.replace에서 원하는 부분으로 바꿔주도록 한다. 위에 설정은 .apk 부분을 버전 코드를 넣어서 바꾼 부분이다.

이렇게 하면 apk가 생성되었을 때 버전 코드가 같이 붙어나오므로 보기도 편하고 관리도 쉽다. 


+ Recent posts