태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

안드로이드용 영어 어학기 Smart LC

스마트LC 소개 링크:
http://blog.ehxm.net/123

티스토어 링크:
http://bit.ly/awW3XW

[안드로이드 샘플코드] 미디어 스캐닝 Class

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/06/10 23:12

수동으로 미디어 스캔을 하는 클래스입니다. 강제 Media Scan Sample Source

import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;

public class MediaScanner {

        private MediaScannerConnection mediaScanConn = null;

        private MusicSannerClient client = null;

        private String filePath = null;
        
        private String fileType = null;
        
        private String[] filePaths = null;
    /**
     *  Then call the MediaScanner  .scanFile("/sdcard/2.mp3");
     * */
        public MediaScanner(Context context) {
        // Create MusicSannerClient  
                if (client == null) {

                        client = new MusicSannerClient();
                }

                if (mediaScanConn == null) {

                        mediaScanConn = new MediaScannerConnection(context, client);
                }
        }

        class MusicSannerClient implements
                        MediaScannerConnection.MediaScannerConnectionClient {

                public void onMediaScannerConnected() {
                        
                        if(filePath != null){
                                
                                mediaScanConn.scanFile(filePath, fileType);
                        }
                        
                        if(filePaths != null){
                                
                                for(String file: filePaths){
                                        
                                        mediaScanConn.scanFile(file, fileType);
                                }
                        }
                        
                        filePath = null;
                        
                        fileType = null;
                        
                        filePaths = null;
                }

                public void onScanCompleted(String path, Uri uri) {
                        // TODO Auto-generated method stub
                        mediaScanConn.disconnect();
                }

        }
        
    /**
     *  Scan file label information  
     * @param filePath  File path eg  :/sdcard/MediaPlayer/dahai.mp3
     * @param fileType  File type eg  : audio/mp3  media/*  application/ogg
     * */
        public void scanFile(String filepath,String fileType) {

                this.filePath = filepath;
                
                this.fileType = fileType;
        // After the connection has been called the onMediaScannerConnected MusicSannerClient  () Method  
                mediaScanConn.connect();
        }
    /**
     * @param filePaths  File path  
     * @param fileType  File types  
     * */
        public void scanFile(String[] filePaths,String fileType){
                
                this.filePaths = filePaths;
                
                this.fileType = fileType;
                
                mediaScanConn.connect();
                
        }
        
        public String getFilePath() {

                return filePath;
        }

        public void setFilePath(String filePath) {

                this.filePath = filePath;
        }

        public String getFileType() {
                
                return fileType;
        }

        public void setFileType(String fileType) {
                
                this.fileType = fileType;
        }

        
}
저작자 표시

관련 TAG로 검색해보세요. : android, CODE, media, mediascan, sample, 안드로이드

¬ COMMENT [0]

여러분의 커뮤니케이션을 기다리고 있습니다.

  1. : 이름
  2. : 홈페이지

  1. : 비밀번호

[안드로이드 샘플코드] ViewSwitcher

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/06/08 22:16


public class ViewSwitcherExample extends ListActivity
				 implements OnClickListener {
    
	//sample list items
	static final String[] ITEMS = new String[]
          { "List Item 1", "List Item 2", 
            "List Item 3", "List Item 4", 
            "List Item 5", "List Item 6", 
            "List Item 7", "List Item 8", 
            "List Item 9", "List Item 10" };
	
	//the ViewSwitcher
	private ViewSwitcher switcher;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);
	  
	  //no window title
	  requestWindowFeature(Window.FEATURE_NO_TITLE);
	  
	  //create the ViewSwitcher in the current context
	  switcher = new ViewSwitcher(this);
	  
	  //footer Button: see XML1
	  Button footer = (Button)View.inflate(this, R.layout.btn_loadmore, null);
	  
	  //progress View: see XML2
	  View progress = View.inflate(this, R.layout.loading_footer, null);
	  
	  //add the views (first added will show first)
	  switcher.addView(footer);
	  switcher.addView(progress);
	  
	  //add the ViewSwitcher to the footer
	  getListView().addFooterView(switcher);
	  
	  //add items to the ListView
	  setListAdapter(new ArrayAdapter(this,
	          android.R.layout.simple_list_item_1, ITEMS));
	}

	@Override /* Load More Button Was Clicked */
	public void onClick(View arg0) {
		//first view is showing, show the second progress view
		switcher.showNext();
		//and start background work
		new getMoreItems().execute();
	}
	
	/** Background Task To Get More Items**/
	private class getMoreItems extends AsyncTask {
		@Override
		protected Object doInBackground(Void… params) {
			//code to add more items
			//...
			try {
				Thread.sleep(3000); //only to demonstrate
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			return null;
		}

		@Override /* Background Task is Done */
		protected void onPostExecute(Object result) {
			//go back to the first view
			switcher.showPrevious();
                        //update the ListView
		}
	}
}
저작자 표시

관련 TAG로 검색해보세요. : android, CODE, sample, viewswitcher, 안드로이드

¬ COMMENT [0]

여러분의 커뮤니케이션을 기다리고 있습니다.

  1. : 이름
  2. : 홈페이지

  1. : 비밀번호

[안드로이드 샘플코드] Database

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/06/08 19:29


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBAdapter 
{
    public static final String KEY_ROWID = "_id";
    public static final String KEY_ISBN = "isbn";
    public static final String KEY_TITLE = "title";
    public static final String KEY_PUBLISHER = "publisher";    
    private static final String TAG = "DBAdapter";
    
    private static final String DATABASE_NAME = "books";
    private static final String DATABASE_TABLE = "titles";
    private static final int DATABASE_VERSION = 1;

    private static final String DATABASE_CREATE =
        "create table titles (_id integer primary key autoincrement, "
        + "isbn text not null, title text not null, " 
        + "publisher text not null);";
        
    private final Context context; 
    
    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public DBAdapter(Context ctx) 
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }
        
    private static class DatabaseHelper extends SQLiteOpenHelper 
    {
        DatabaseHelper(Context context) 
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) 
        {
            db.execSQL(DATABASE_CREATE);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, 
        int newVersion) 
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion 
                    + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }    
    
    //---opens the database---
    public DBAdapter open() throws SQLException 
    {
        db = DBHelper.getWritableDatabase();
        return this;
    }

    //---closes the database---    
    public void close() 
    {
        DBHelper.close();
    }
    
    //---insert a title into the database---
    public long insertTitle(String isbn, String title, String publisher) 
    {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_ISBN, isbn);
        initialValues.put(KEY_TITLE, title);
        initialValues.put(KEY_PUBLISHER, publisher);
        return db.insert(DATABASE_TABLE, null, initialValues);
    }

    //---deletes a particular title---
    public boolean deleteTitle(long rowId) 
    {
        return db.delete(DATABASE_TABLE, KEY_ROWID + 
        		"=" + rowId, null) > 0;
    }

    //---retrieves all the titles---
    public Cursor getAllTitles() 
    {
        return db.query(DATABASE_TABLE, new String[] {
        		KEY_ROWID, 
        		KEY_ISBN,
        		KEY_TITLE,
                KEY_PUBLISHER}, 
                null, 
                null, 
                null, 
                null, 
                null);
    }

    //---retrieves a particular title---
    public Cursor getTitle(long rowId) throws SQLException 
    {
        Cursor mCursor =
                db.query(true, DATABASE_TABLE, new String[] {
                		KEY_ROWID,
                		KEY_ISBN, 
                		KEY_TITLE,
                		KEY_PUBLISHER
                		}, 
                		KEY_ROWID + "=" + rowId, 
                		null,
                		null, 
                		null, 
                		null, 
                		null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    //---updates a title---
    public boolean updateTitle(long rowId, String isbn, 
    String title, String publisher) 
    {
        ContentValues args = new ContentValues();
        args.put(KEY_ISBN, isbn);
        args.put(KEY_TITLE, title);
        args.put(KEY_PUBLISHER, publisher);
        return db.update(DATABASE_TABLE, args, 
                         KEY_ROWID + "=" + rowId, null) > 0;
    }
}
출처: http://www.devx.com/wireless/Article/40842/1954
저작자 표시

관련 TAG로 검색해보세요. : android, CODE, Database, sample, 안드로이드

¬ COMMENT [0]

여러분의 커뮤니케이션을 기다리고 있습니다.

  1. : 이름
  2. : 홈페이지

  1. : 비밀번호

[안드로이드] 느린 Canvas.drawLine을 쓰지말라..

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/04/06 01:40


Canvas.drawLine으로 많은 선을 draw할 경우에는 선을 그리는 계산을 많이 하기 때문에 리소스를 많이 사용하게 된다.
만약 drawLine으로 수직선이나 수평선을 그릴 경우에는 drawRect로 하는게 더 빠르다.

canvas.drawLine(x,y,x,y1,paint) 와 같은 굵기가 1인 y에서 y1으로 수직선을 draw할때는
canvas.drawRect(x,y,x+1,y1,paint) 와 같이 너비가 1인 사각형으로 구현하는 것이 더 좋다. 

저작자 표시

관련 TAG로 검색해보세요. : android, Canvas, drawline, drawrect, SurfaceView, 안드로이드

¬ COMMENT [0]

여러분의 커뮤니케이션을 기다리고 있습니다.

  1. : 이름
  2. : 홈페이지

  1. : 비밀번호

[안드로이드] 액티비티 Activity 방향 설정하기

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/03/03 13:00

안드로이드 액티비티의 방향을 설정하는 방법입니다.
AndroidManifest.xml 파일의 <activity>의 android:screenOrientation속성으로 조절이 가능합니다.

만약 OrientationActivity라는 액티비티를 가로로 설정하려면 다음과 같이 AndroidManifest.xml 파일의 속성을 변경해 줍니다.

<activity android:name=".OrientationActivity"
          android:screenOrientation="landscape">
 
android:screenOrientation로 지정할 수 있는 속성은 다음과 같습니다.
"unspecified" System에서 디바이스에 따라 방향을 결정
"landscape" 가로방향
"portrait" 세로방향
"user" 사용자 설정
"behind" 이전 액티비티의 스택에 따라 결정
"sensor" 가속 센서의 방향에 따라 결정
"nosensor" 가속 센서를 사용하지 않음. "unspecified"와 비슷


이 외의 activity 속성은 아래 페이지에 잘 나와 있습니다.
http://developer.android.com/guide/topics/manifest/activity-element.html
저작자 표시

관련 TAG로 검색해보세요. : activity, android, 방향, 안드로이드, 액티비티

¬ COMMENT [0]

여러분의 커뮤니케이션을 기다리고 있습니다.

  1. : 이름
  2. : 홈페이지

  1. : 비밀번호

[안드로이드] 영어 어학기 어플

영어 듣기 공부 많이들 하시나요? 따로 어학기를 장만하시기는 비용이 들죠? 스마트폰에서 MP3 파일을 터치를 이용해서 자유롭게 듣을 수 있는 영어 어학기 어플입니다. 동아리.....

2010년 대한민국 매쉬업 경진대회 후기, 아이디어 전쟁을 다녀와서..

아이디어의 전쟁의 현장이었던 2010년 대한민국 매쉬업 경진대회에 다녀왔습니다. 이번 대회는 지난 2월 6일(토요일), 삼성동 코엑스 컨퍼런스룸 401에서 열렸습니다. 이번.....

2010년 100가지가 넘는 안드로이드폰이 몰려온다!

2010년에 100가지가 넘는 안드로이드 폰 출시가 될 예정입니다. Mobile World Congress keynote에서 Google CEO Eric Schmidt의 연설.....

[안드로이드] 모토로이 체험할 수 있는 곳 (전국)

서울, 안양, 부산, 대구, 광주, 대전에 안드로이드 폰 체험 할 수 있는 곳이 있네요. 저는 코엑스 메가박스 입구에 있는 모토로라 체험 부스에서 우연히 모토로이를 만져보게 되.....

위 3D 갤러리는 http://www.fotoviewr.com/ 사이트의 Fotoviewr 입니다. Flex와 Papervision3D를 이용하여 위와같은 3D 갤러리를 구현해.....

언톡 2010년 신입생 모집 포스터
Android, LEGO NXT를 이용한 Sudoku Solving Robot 제작
Android, LEGO NXT를 이용한 Sudoku Solving Robot 제작
Android, LEGO NXT를 이용한 Sudoku Solving Robot 제작
Android, LEGO NXT를 이용한 Sudoku Solving Robot 제작
Android, LEGO NXT를 이용한 Sudoku Solving Robot 제작
뻗어버린 트위터
애니콜 드리머즈 7기 2차 합격!
김경호를 소개합니다! - 애니콜 드리머즈 Explorer 7기 지원
1 2 3

Category

전체보기 (105)
Anycall Dreamers (3)
안드로이드 (35)
Adobe Flash Platform (20)
Algorithm (0)
개발노트 (6)
경험 (33)

글 보관함

2010/08 (1)

2010/07 (2)

2010/06 (4)

2010/05 (1)

2010/04 (4)

Calendar

«   2010/09   »
      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    

믹시


Total : 61,659 Today : 142 Yesterday : 180