본문 바로가기

컴퓨터/안드로이드

안드로이드 - MP3 재생 안드로이드 - MP3 재생 하기 예제 1. 리소스 안의 mp3 재생 - getResources().getIdentifier()로 경로를 알아온다. tmpID = getApplicationContext().getResources().getIdentifier( "sound", "raw", "aa.bb.man"); Context con = getApplicationContext(); mp = MediaPlayer.create(con, tmpID); mp.start(); 2. sdcard안의 mp3재생 - setDataSource()를 이용해서 음원의 경로를 설정 String songPath = "/sdcard/man.mp3"; mp.setDataSource(songPath); 주요 메서드 : 1.prepare.. 더보기
안드로이드 - 텍스트뷰 부분색상 안드로이드 - 텍스트뷰 부분색상 주기 final SpannableStringBuilder sp = new SpannableStringBuilder("Hellow"); sp.setSpan(new ForegroundColorSpan(Color.RED), 1, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.append(sp); 더보기
안드로이드 - 한글 Bold 효과주기 - 한글 Bold 효과주기 - EditText.setPaintFlags(EditText.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG); 더보기
안드로이드 - 진행바 예제 1) 프로그래스 바 - 원 모양 : 작업의 전체 분량을 미리 알 수 없을 때 사용. (default) - 막대 모양 : 작업 분량을 미리 알고 있을 때 사용 style = "?android:Attr/progressBarStyleHorizontal" void setProgress (int progress) void setSecondaryProgress (int secondaryProgress) void incrementProgrssBy (int diff) void incrementSecondaryProgressBy (int diff) ==================================== ex =================================== - layout - 더보기
안드로이드 - 파일카피 예제 package com.copytest; import java.io.FileInputStream; import java.io.FileOutputStream; public class FileCopy { 안드로이드 - 파일카피 예제 public static String read( String source ) throws Exception { FileInputStream input = new FileInputStream( source ) ; long size = input.available( ) ; byte buff[ ] = new byte[ (int)size ] ; input.read( buff ) ; input.close( ) ; return( new String( buff ) ) ; } public sta.. 더보기
안드로이드 - 인텐트예제 안드로이드 - 인텐트예제 // 웹페이지 띄우기 Uri uri = Uri.parse("http://www.google.com"); Intent it = new Intent(Intent.ACTION_VIEW,uri); startActivity(it); // 구글맵 띄우기 Uri uri = Uri.parse("geo:38.899533,-77.036476"); Intent it = new Intent(Intent.Action_VIEW,uri); startActivity(it); // 구글 길찾기 띄우기 Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=출발지주소&daddr=도착지주소&hl=ko"); Intent it = new Intent(Intent.AC.. 더보기
인터넷 연결 가능 여부 // 인턴넷(WiFi or 3G) 연결이 가능 한지 채크 한다. public boolean isInternet() { boolean isuse = true; try { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nim = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo niw = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); //boolean isWifiAvail = ni.isAvailable(); if(nim.isConnected()==true ||.. 더보기
안드로이드 - 내장아이콘 사용하기 java code myMenuItem.setIcon(android.R.drawable.ic_menu_save); Resource Usage android:icon="@android:drawabel/ic_menu_save" 더보기