2017년 3월 29일 수요일

android 볼륨 up down 방법

private int mStreamType = AudioManager.STREAM_MUSIC;

public void volumeUp() {
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);    int currVol = am.getStreamVolume(mStreamType);    int maxVol = am.getStreamMaxVolume(mStreamType);
    if (currVol < maxVol) {
        am.setStreamVolume(mStreamType, currVol + 1, AudioManager.FLAG_PLAY_SOUND);    }
}

public void volumeDown() {
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);    int currVol = am.getStreamVolume(mStreamType);    if (currVol > 0) {
        am.setStreamVolume(mStreamType, currVol - 1, AudioManager.FLAG_PLAY_SOUND);    }
}

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  값 : *
확인   > 재시작