달력

4

« 2024/4 »

  • 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
반응형
728x90
반응형

안드로이드 - 자기 IP주소 가져오기

원본 출처 :http://eduinfo.pe.kr/bbs/board.php?bo_table=01_6&wr_id=2549

   public String getLocalIpAddress() {
      try {
              Enumeration<NetworkInterface> en =  NetworkInterface.getNetworkInterfaces();
              while(en.hasMoreElements()) {
                     NetworkInterface interf = en.nextElement();
                     Enumeration<InetAddress> ips = interf.getInetAddresses();
                          while (ips.hasMoreElements()) {
                            InetAddress inetAddress = ips.nextElement();
                            if (!inetAddress.isLoopbackAddress()) {
                                    return inetAddress.getHostAddress().toString();
                         }
                  }
              }
      } catch (SocketException ex) {
              Log.e("Error", ex.toString());
      }
          return null;
    }
728x90
반응형
:
Posted by mapagilove
728x90
반응형

열공 안드로이드 - 안드로이드에서 db(sqlite) 쉽게 보기 

원본 출처: [블로그 링크] http://onjo.tistory.com/2052



안드로이드에서 db(sqlite) 정보를 
쉽게 보는 방법을 정리해 보았습니다.

(초보자를 위한 팁 이라고 생각합니다.)



핵심만 정리하면 아래와 같습니다.

(1) db 내보내기 (db export / data.sqlite)
=> 이클립스 혹은 Droid Explorer 이용


(2) db 보기
=> firefox 확장 도구인 SQLite Manager를 이용하여
    (1) 에서 추출한 db(data.sqlite)를 열면 됩니다.

    * mysql에서 mysqlyog를 사용하는 것과 비슷한 개념

================================================

안드로이드에서 db(sqlite) 쉽게 보기


1. Run Eclipse (이클립스 실행)


2. Select Project (프로젝트 선택) 
   -> Run Android Emulator (안드로이드 에뮬레이터 실행)


3. Select "DDMS perspective" (DDMS 선택)
   -> File Explorer
   -> data - data - package name (패키지명)
      - databases - data 선택




4. select "pull a file from the device" (pull 선택)
   -> save the "data.sqlite" (db export / db 내보내기)


======================================================

5. View DB (DB 내용 보기)
  1) Firefox :: SQLite Manager
     http://code.google.com/p/sqlite-manager/

      => firefox browser, click the *.xpi (firefox에서 xpi 클릭하면 설치됨)
  

  2) click the "Connect Database" (DB 연결 버튼 클릭)


======================================================
※ Eclipse the not view "File Explorer"
(이클립스에서 File Explorer가 내용이 안보일 경우)

=> Droid Explorer 이용해 db export
- Droid Explorer : http://de.codeplex.com/



6. Conclusion (정리)
  1) db export (db 내보내기)
     - eclipse DDMS 혹은 Droid Explorer

  2) view db (db 보기)
    - firefox SQLite Manager
728x90
반응형
:
Posted by mapagilove
728x90
반응형

안드로이드 - 특정 앱 설치 여부 확인 및 마켓 이동 소스

원본출처: http://blog.daum.net/satapon/111

 

- 어플목록(정확히는 패키지들) 출력하는 소스 

ArrayList<String> apps = new ArrayList<String>();
       List<PackageInfo> packs = getPackageManager().getInstalledPackages(0); 
        
       for(int j = 0 ; j < packs.size(); j++){
       apps.add(packs.get(j).packageName);
       }
       for(int j = 0 ; j < apps.size(); j++){

           Log.i("test",apps.get(j));    
       }

 

-  설치여부 확인후 없으면 마켓으로 이동하는 소스

http://baeksupervisor.tistory.com/120

 

- 안드로이드에서 마켓 링크 따기

http://jely.egloos.com/4433500

 

- 응용한 마켓 다운로드 여부 확인하는 다이얼 로그 함수

//pdf지원 어플리케이션의 마켓검색을 묻고, 종료하는 다이얼로그 호출
    public void viewPdfInstallDialog()
    {
     String alertTitle = getResources().getString(R.string.app_name);
  String buttonMessage = "현재 pdf문서를 지원하는 프로그램이 없습니다. 마켓에서 검색하시겠습니까?";//getResources().getString(R.string.alert_msg_exit);
  String buttonYes = "네";//getResources().getString(R.string.button_yes);
  String buttonNo = "아니오";//getResources().getString(R.string.button_no);
     
  new AlertDialog.Builder(LoadPDFActivity.this)
  .setTitle(alertTitle)
  .setMessage(buttonMessage)
  .setPositiveButton(buttonYes, new DialogInterface.OnClickListener() 
  {
 
   public void onClick(DialogInterface dialog, int which) 
   {
       //검색
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pdf"));
    startActivityForResult(intent, 0);
   }
  })
  .setNegativeButton(buttonNo, new DialogInterface.OnClickListener() 
  {
 
   public void onClick(DialogInterface dialog, int which) 
   {
       //종료
    finish();
   }
  })
  .show();
    }

728x90
반응형
:
Posted by mapagilove
728x90
반응형

 

안드로이드 - 이클립스에서 DDMS(Dalvik Debug Monitor Service) 사용하기

 

원본출처:http://androidhuman.tistory.com/81

  안드로이드 어플리케이션을 개발할 때, 보통 안드로이드 에뮬레이터를 사용하게 됩니다. 안드로이드 어플리케이션 개발에서는 에뮬레이터 뿐만 아니라 DDMS(Dalvik Debug Monitor Service)를 사용하여 가상으로 전화나 SMS를 보내줄 수도 있고, 위치 정보를 수정해 주는 것도 가능합니다. 즉, 실제 단말기를 가지고 있는 것처럼 시뮬레이션 해 주는 것이 가능한 것이죠.

이러한 DDMS는 이클립스 플러그인인 ADT를 설치하셨다면, 이클립스 상에서 바로 실행이 가능합니다. (저는 이걸 몰라서 맨날 tools 폴더에 들어가서 수동으로 ddms를 실행했었습니다 -_-;;) 실행 방법은 의외로 상당히 간단합니다. 

이클립스 메뉴의 Window -> Open Perspective -> Other... 를 클릭하시면 다음과 같은 화면이 나오게 됩니다.


여기에서 DDMS를 선택하시고, OK버튼을 누르시면 다음과 같은 화면이 나오게 됩니다.


여기에서 왼쪽의 "Devices" 항목의 툴바 중 가장 오른쪽에 있는 "Screen Capture"를 이용하여 화면 캡쳐를 할 수 있고, "Emulator Control" 항목을 통해서 가상으로 전화, SMS를 발송하거나 위치 정보를 수정할 수 있습니다.

728x90
반응형
:
Posted by mapagilove
728x90
반응형

안드로이드 - sqlite export import

 

http://hxcaine.com/blog/2010/09/14/backing-up-importing-and-restoring-databases-on-android/

 

If your Android application has a database and you want your users to be able to backup the database and restore it as they see fit, you’ll need to mess about with database files.

Below is a class called DbExportImport. Once you’ve set it up with the correct values, all you need to do is call exportDb(), importDb() or restoreDb() from your application to perform the necessary operations.

This is also useful as a temporary measure when changing your package name or key for application signing, as your application will be newly installed and you will lose your database.

I have only left in a few comments, so for any clarification, leave a comment and I’ll make it a little clearer.

728x90
반응형
:
Posted by mapagilove
728x90
반응형

안드로이드 - 미디어 스캐닝하기

전체 스캐닝 하기
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));

원하는 파일만 스캐닝하기
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+ "폴더위치"+"파일이름"+".파일확장자")));

728x90
반응형
:
Posted by mapagilove
반응형