posted by Full-stack Developer 2011. 5. 13. 17:51

보내는 부분
Intent DetailView = new Intent(현제클레스.this, 받는엑티비티클레스이름.class);
       DetailView.putExtra("URL", "데이터를 넣는자리");
       startActivity(DetailView);

★현제클레스.this 이부분에 this(extends Activity한클레스의)를 넣어줘도되고 해당 Activity의 Context를 넣어줘도되고 기호에 맞게 ㅋ

받는 부분
Intent idv = getIntent();
  
  String url = idv.getStringExtra("URL");

★url에 "데이터를 넣는자리" 가 들어가겠죠..

posted by Full-stack Developer 2011. 5. 13. 17:46


File datafile = new File("/sdcard/filename.txt");
  StringBuilder data = new StringBuilder(); 
  try {    
   BufferedReader reader = new BufferedReader(new FileReader(datafile));    
   String readdata;     
   while ((readdata = reader.readLine())!=null) {        
    data.append(readdata); 
    }
   } catch (IOException e) {    
   }
  }



String tmp="";
String url="/sdcard/filename.txt";
  
  try {
   BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(url)), "UTF-8"));
   String line;     
   while ((line = br.readLine()) != null) {        
    tmp+=line;
   }
  } catch (IOException e) { 
  }


FileInputStream fis = new FileInputStream(url);
   Reader in = new InputStreamReader(fis, "UTF-16");
   String tmp="";
   char []buf = new char[fis.available()];
   in.read(buf);
   tmp = new String(buf);
   fis.close();

posted by Full-stack Developer 2011. 5. 13. 13:46

리소스의 이미지 load

Bitmap bitMapImage = BitmapFactory.decodeResource(getResources(), R.drawable.bar_port);

sdcard의 이미지 load

Bitmap bitMapImage = BitmapFactory.decodeFile("/sdcard/img.jpg");
posted by Full-stack Developer 2011. 5. 13. 13:42

Bitmap -> Drawable

Bitmap bitmap = new Bitmap (...);

Drawable drawable = new BitmapDrawable(bitmap);


Drawable -> Bitmap

Bitmap bitmap = Bitmap.createBitmap(width, height, true);
Drawable iconDrawable =
packageManager.getActivityIcon(resolveInfo.activityInfo);
Canvas canvas = new Canvas(bitmap);

drawable.setBounds(0, 0, width, height);
drawable.draw(canvas);

posted by Full-stack Developer 2011. 5. 12. 10:20

 


posted by Full-stack Developer 2011. 5. 12. 10:19

 


posted by Full-stack Developer 2011. 4. 25. 11:04


1.화면이 가로, 세로 변경시 이벤트

@Override
    public void onConfigurationChanged(Configuration newConfig) {

      super.onConfigurationChanged(newConfig);
       int cnt=0;
         switch(newConfig.orientation){

            case Configuration.ORIENTATION_LANDSCAPE:
             //TODO
            break;

            case Configuration.ORIENTATION_PORTRAIT:  
            //TODO
            break;

         } 
    
    }

2.현제 화면이 가로, 세로인지 확인
Configuration config = getResources().getConfiguration();
if(config.orientation == Configuration.ORIENTATION_PORTRAIT){
 //TODO
}
else if(config.orientation == Configuration.ORIENTATION_LANDSCAPE){
 //TODO
}

posted by Full-stack Developer 2011. 4. 18. 13:22


@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        requestWindowFeature(Window.FEATURE_NO_TITLE);//타이틀바 제거
        setContentView(R.layout.main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//풀스크린

    }

posted by Full-stack Developer 2011. 4. 14. 11:32
WebView wv = new WebView(this);
wv.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); 
posted by Full-stack Developer 2011. 4. 14. 11:05

 

WebView wv = new WebView(this);


wv.setVerticalScrollBarEnabled(false); 
wv.setHorizontalScrollBarEnabled(false);

posted by Full-stack Developer 2011. 4. 5. 11:13
VideoView vv = (VideoView)findViewById(R.id.videoView1);
       MediaController mc =  new MediaController(this);
       vv.setVideoURI(Uri.parse("rtsp://xxxxxxxxxx/xxxxx.mp4"));
       vv.setMediaController(mc);
       vv.start();

경로가 rtsp(Real Time Streaming Protocol)경로여야 한다.
posted by Full-stack Developer 2011. 3. 31. 10:47
 
보이기
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

숨기기
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);

출처 http://eddykudo.com/45
posted by Full-stack Developer 2011. 3. 30. 10:14

// 웹페이지 띄우기    

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.ACTION_VIEW,URI);    

startActivity(it);    

  

// 다이얼러 띄우기   

Uri uri = Uri.parse("tel:xxxxxx");    

Intent it = new Intent(Intent.ACTION_DIAL, uri);   

startActivity(it);   

  

// 전화걸기   

// 퍼미션을 잊지 마세요. <USES-PERMISSION id=android.permission.CALL_PHONE />    

Uri uri = Uri.parse("tel.xxxxxx");    

Intent it = new Intent(Intent.ACTION_CALL,uri);    

startActivity(it);   

  

// SMS/MMS 발송    

Intent it = new Intent(Intent.ACTION_VIEW);    

it.putExtra("sms_body""The SMS text");    

it.setType("vnd.android-dir/mms-sms");    

startActivity(it);   

  

// SMS 발송    

Uri uri = Uri.parse("smsto:0800000123");    

Intent it = new Intent(Intent.ACTION_SENDTO, uri);    

it.putExtra("sms_body""The SMS text");    

startActivity(it);   

  

// MMS 발송    

Uri uri = Uri.parse("content://media/external/images/media/23");    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra("sms_body""some text");    

it.putExtra(Intent.EXTRA_STREAM, uri);    

it.setType("image/png");    

startActivity(it);     

  

// 이메일 발송    

Uri uri = Uri.parse("mailto:xxx@abc.com");    

Intent it = new Intent(Intent.ACTION_SENDTO, uri);    

startActivity(it);    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");    

it.putExtra(Intent.EXTRA_TEXT, "The email body text");    

it.setType("text/plain");    

startActivity(Intent.createChooser(it, "Choose Email Client"));   

Intent it = new Intent(Intent.ACTION_SEND);   

String[] tos = {"me@abc.com"};   

String[] ccs = {"you@abc.com"};   

it.putExtra(Intent.EXTRA_EMAIL, tos);   

it.putExtra(Intent.EXTRA_CC, ccs);   

it.putExtra(Intent.EXTRA_TEXT, "The email body text");   

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   

it.setType("message/rfc822");   

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// extra 추가하기    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");    

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");    

sendIntent.setType("audio/mp3");    

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// 미디어파일 플레이 하기    

Intent it = new Intent(Intent.ACTION_VIEW);    

Uri uri = Uri.parse("file:///sdcard/song.mp3");    

it.setDataAndType(uri, "audio/mp3");    

startActivity(it);    

Uri uri = Uri.withAppendedPath(    

  MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");    

Intent it = new Intent(Intent.ACTION_VIEW, uri);    

startActivity(it);   

  

// 설치 어플 제거    

Uri uri = Uri.fromParts("package", strPackageName, null);    

Intent it = new Intent(Intent.ACTION_DELETE, uri);    

startActivity(it);    

  

// APK파일을 통해 제거하기    

Uri uninstallUri = Uri.fromParts("package""xxx"null);    

returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);    

  

// APK파일 설치    

Uri installUri = Uri.fromParts("package""xxx"null);    

returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);    

  

// 음악 파일 재생    

Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");    

returnIt = new Intent(Intent.ACTION_VIEW, playUri);    

  

// 첨부파일을 추가하여 메일 보내기    

Intent it = new Intent(Intent.ACTION_SEND);   

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");   

sendIntent.setType("audio/mp3");   

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// 마켓에서 어플리케이션 검색 (패키지명은 어플의 전체 패키지명을 입력해야 합니다.)   

Uri uri = Uri.parse("market://search?q=pname:pkg_name");   

Intent it = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(it);   

  

// 마켓 어플리케이션 상세 화면 (아이디의 경우 마켓 퍼블리싱사이트의 어플을 선택후에 URL을 확인해보면 알 수 있습니다.)  

Uri uri = Uri.parse("market://details?id=어플리케이션아이디");   

Intent it = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(it);   

  

// 구글 검색    

Intent intent = new Intent();    

intent.setAction(Intent.ACTION_WEB_SEARCH);    

intent.putExtra(SearchManager.QUERY,"searchString")    

startActivity(intent);  

출처: http://hoya4232.tistory.com/716
[출처] http://snipt.net/Martin/tag/android

posted by Full-stack Developer 2011. 2. 16. 09:12


빨간색 박스안에 알맞게 변경해주면된다.
fill_parent를 사용하든.. wrap_content를 사용하든.. 수치를 직접넣든... 등등
posted by Full-stack Developer 2011. 2. 11. 15:01


webview.getSettings().setUseWideViewPort(true);

ture면 자동개행 안하는것이고

false면 자동개행 한다는 것임.

default는 false로 되있음.
posted by Full-stack Developer 2011. 2. 11. 09:15

기존에 TextView의 paint를 가져와 breakword를 사용하여 개행을 시도해보았지만

단어단위로 개행은 했지만 양끝정렬처럼 깔끔하게 실행되지 않은 문제가 있었습니다.

그리하여 WebView를 이용하여 Text를 뿌려준결과 양끝정렬을 하여 텍스트가 깔끔하게

개행되었습니다.



posted by Full-stack Developer 2011. 1. 20. 08:56


TextView 단어 단위로 개행 하는 코드입니다.
기본적으로 개행할때 공백(스페이스바)단위로 개행해서
라인이 들쑥날쑥해서 보기 않좋더라구요...
그래서 구현한건데... 뭐 그목적은아니지만..
아... 나름 힘들었음 ^^
아! 저기 float frameWidth는 택스트뷰의 width를 가져오시면 됩니다.
뭐 쭉보시면 이해하실꺼에요 ^^
posted by Full-stack Developer 2011. 1. 6. 18:01



new StringTokenizer(문자열,토큰할문자열);
ex)
      문자열 : 1|12|123|      
      토큰할문자열: |
      결과: 1
              12
              123