Notification

old/UI Design 2010. 6. 17. 15:57
1. Toast Notification
 
    1) Basic
      
Toast.makeText(context, text, duration).show();


    2) Custom
      
    Context context = getApplicationContext();   // Context 얻어오기
    LayoutInflater inflater = getLayoutInflater();   // inflater 불러들이기
    View layout = inflater.inflate(R.layout.custom_layout, (ViewGroup) findViewById(R.id.toast_layout_root));  // custom_layout에서 toast_layout_root를 확장하기 위해 불러오자.
   
    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(android.R.drawable.ic_dialog_alert);
   
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText("This is a custom Toast");
   
    Toast toast = new Toast(context);
    toast.setGravity(Gravity.BOTTOM, 0,0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
    toast.show();


2. Status Bar Notification

    1) Basic
   
        (1) notification manager에 대한 reference 얻기 
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager)getSystemService(ns);

        (2) notification의 instance화 하기
int icon = R.drawable.notification_icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);

        (3) notification 확장 및 intent 정의
Context contex = getApplicaitonContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World";
Intent notificationintent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, conentIntent);

       (4) notification manager에게 notification 전달
private static final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);

     
      (5) option 기능들
[sound 설정]
notification.defaults |= Notification.DEFAULT_SOUND;  // 기본 sound 재생
notification.sound = Uri.parse(file:///위치지정);  // 디바이스 sdcard에서 찾기
notification.sound = Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "번호");  // Media Store에서 사용

[진동 설정]
notification.defaults |= Notification.DEFAULT_VIBRATE;  // 기본 설정으로
long[] vibrate = {0,100,200,300}; // {시작전대기, 진동길이, 꺼진후대기,...}
notification.vibrate = vibrate;

'old > UI Design' 카테고리의 다른 글

String & StyledText  (0) 2010.06.30
Style & Theme  (0) 2010.06.30
UI 이벤트 처리  (0) 2010.06.15
style  (0) 2010.02.22
기본 UI 생성 순서  (0) 2010.02.22
Posted by jazzlife
,

UI 이벤트 처리

old/UI Design 2010. 6. 15. 17:17
1. 이벤트 리스너(Listener)

   View.OnClickListener -> onClick()

   View.OnFocusChangeListener -> onLongClick(), onFocusChange()

   View.OnKeyListener -> onKey()

   View.OnTouchListener -> onTouch()

   View.OnCreateContextMenuListener -> onCreateContextMenu()


[사용법 1]

button.setOnClickListener(mListener);

private OnClickListener mListener = new OnClickListener() {
   public void onClick(View v) {
      }
};


[사용법 2]

public class exActivity extends Activity implements OnClickListener {
  ...
  button.setOnClickListener(this);
}

public void onClick(View v) {
 }
...
}


2. 이벤트 핸들러 (Handler)

  onKeyDown() - 신규 키 이벤트 발생 시 호출

  onKeyUp() - 키 up 이벤트 발생 시 호출

  onTrackballEvent() - 트랙볼 모션 이벤트가 발생할 시 호출

  onFocusChanged() - View가 Focus를 잃거나 얻을 때 호출

Activity.dispatchTouchEvent - 이벤트가 윈도우로 전달되기 전에 액티비티가 가로챌 수 있게 허용한다.
ViewGroup.onInterceptTouchEvent - 부모 뷰가 자식 뷰의 이벤트를 감시하도록 허용한다.
ViewParent.requestDisallowInterceptTouchEvent - 부모 뷰가 이벤트를 가로채면 안된다는 것을 가리킨다.


3. 터치(Touch) 모드

터치 디바이스에서는 스크린 터치 시 터치모드로 진입하게 되고 isFocusableTouchMode가 true인 뷰들만 포커스 될 것이다. isInTouchMode()를 호출하여 디바이스가 터치모드에 있는지 확인 할 수 있다.


4. 포커스(Focus) 처리

프레임워크는 사용자 입력에 반응하여 포커스의 움직임을 처리한다.
isFocusable()을 통해 포커스를 가지고자 하는지 확인할 수 있고 setFocusable()를 사용하여 포커스를 허용하게 변경할 수 있다. 포커스의 이동은 nextFocusDown~nextFocusUp으로 xml에서 정의할 수 있다.

[순환 포커스 이동] - 최상위와 최하위도 상하로 순환하도록 지정하는 xml 수정
<LinearLayout
   ...
   <Button android:id="@+id/Top"
               android:nextFocusUp="@+id/Bottom"
                .../>
   <Button android:id="@+id/Bottom"
               android:nextFocusDown="@+id/Top"
                .../>
</LinearLayout>

특정 뷰에게 포커스를 넘기도록 요청하려면 requestFocus()를 호출한다.

'old > UI Design' 카테고리의 다른 글

Style & Theme  (0) 2010.06.30
Notification  (0) 2010.06.17
style  (0) 2010.02.22
기본 UI 생성 순서  (0) 2010.02.22
R.anim  (0) 2010.02.22
Posted by jazzlife
,
 

1. 우분투설치. 안드로이드 개발 기준이 되는 OS는 우분투와 MacOSX 입니다. http://www.ubuntu.com/ 부터 설치합니다.

2. 소스받기. 안드로이드에서 소스 트리를 주욱 다운 받아봅니다. http://source.android.com/download

일단 받고 나서 디렉토리를 살펴보면 저 방대한 소스 트리중 대체 어디서 부터 봐야 하는 것인가라는 생각이 들게 됩니다.

3. 시작하기. development\pdk\docs 에 있는 Android Porting Guide를 읽어봅니다. 최신 소스와는 차이가 있지만 어디서부터 시작을 해야 하는지 방향을 잡아줍니다. 이 숨겨져(?) 있는 문서가 안드로이드 포팅을 위한 소스 분석의 시작포인트입니다.

1, 2번을 생략하고 일단 Document를 읽어보시고 싶으신 분은 웹에서(http://git.source.android.com/) snapshot을 받아서 보실 수 있습니다.

대략적인 소스 구성에 대한 설명을 볼 수 있습니다. 그리고 거기서 나오는 디바이스들 중 비디오, 키, 오디오 정도의 순서로 소스를 따라들어가면 될듯 합니다.

소스를 보고 있으면 가끔 우주를 헤메는 기분이 들고 그게 정상입니다..


Get source

For information about current problems and fixes, see Known issues.

This document describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine.

Related reading:
  • For an overview of the entire code-review and code-update process, see Workflow.
  • For reference details about Repo, see Using Repo and Git.

What's in the source?

For a description of all the projects that make up the Android source code, see Project layout. To see snapshots and histories of the files available in the public Android repositories, visit theGitWeb web interface.
The source is approximentely 2.1GB in size. You will need 6GB free to complete the build.

Setting up your machine

To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported.

Linux

The Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but reports of successes or failures on other distributions are welcome.

Ubuntu Linux (i386)

To set up your Linux development environment, make sure you have the following:
  • Git 1.5.4 or newer and the GNU Privacy Guard.
$ sudo apt-get install git-core gnupg
  • JDK 5.0, update 12 or higher.
$ sudo apt-get install sun-java6-jdk
  • The following packages: flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.
$ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zipcurl libncurses5-dev zlib1g-dev
  • You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.
$ sudo apt-get install valgrind

Ubuntu Linux (amd64)

This has not been as well tested. Please send success or failure reports to repo-discuss@googlegroups.com.

The Android build requires a 32-bit build environment as well as some other tools:
  • Git, JDK, flex, and the other packages as listed above in the i386 instructions:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl
  • Get a 32-bit version of the JVM:

    $ sudo apt-get install sun-java6-jdk # JDK tools (javac, etc)
    $ sudo apt-get install ia32-sun-java6-bin # JRE (java itself)
    $ sudo update-java-alternatives -s ia32-java-6-sun

  • Pieces from the 32-bit cross-building environment:
$ sudo apt-get install lib32z1-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs

Ubuntu doesn't have packages for the X11 libraries, but that can be worked around with the following command:

$ sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so

Other Linux

There's no reason why Android cannot be built on non-Ubuntu systems. Please send any success or failure reports to repo-discuss@googlegroups.com. In general you will need:

Anything missing from this list? Please let us know!


Mac OS

Requirements:

  • To build the Android files in a Mac OS environment, you need an Intel/x86 machine. The Android build system and tools do not support the obsolete PowerPC architecture.
  • Android must be built on a case-sensitive file system.
    • We recommend that you build Android on a partition that has been formatted with the "Case-sensitive Journaled HFS+" file system:
      • A case-sensitive file system is required because the sources contain files that differ only in case.
      • Journaled systems are more robust. (This is optional, but recommended.)
      • HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.
    • If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead.
      • To create the image:
        • launch /Applications/Utilities/Disk Utility
        • select "New Image"
        • size: 8 GB (this will work, but you can choose more if you want to)
        • volume format: case sensitive, journaled
      • This will create a .dmg file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute "mountAndroid":

        # command to mount the android file image
        function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }

        Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.
To set up your Mac OS development environment, follow these steps:
  1. Install the XCode version 2.4 or later from http://developer.apple.com . We recommend version 3.0 or newer.
  2. Install MacPorts. To do this:
    1. Download the tar file from http://www.macports.org/ and untar the files.
    2. Run the following:
      $ ./configure
      $ make
      $ sudo make install
      $ sudo port selfupdate
    3. View your path:
      $ echo $PATH
      Make sure that /opt/local/bin is in your path before /usr/bin. If not, edit $HOME/.bash_profile and add the line "export PATH=/opt/local/bin:$PATH" (or the equivalent for other shells) after any other PATH-related lines. To verify that your path is now correct, open a new terminal and run echo $PATH again.
  3. Upgrade GNU make to 3.81 or later by running
    $ sudo port install gmake
    $ sudo ln -s gmake /opt/local/bin/make
  4. Install libsdl by running
    $ sudo port install libsdl
  5. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your .bash_profile file:
    # set the number of open files to be 1024
    ulimit -S -n 1024
  6. Install Git and the GNU Privacy Guard:
    $ sudo port install git-core gnupg
    (You will need Git 1.5.4 or newer.)
  7. Install these optional packages, if you want to:
    $ sudo port install xemacs +sumo
    $ sudo port install gimp
Note: If you get errors from port install, prefix your commands with POSIXLY_CORRECT=1, for example:
$ POSIXLY_CORRECT=1 sudo port install package-name


Installing Repo

Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Using Repo and Git.

To install, initialize, and configure Repo, follow these steps:

  1. Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path:
    $ cd ~
    $ mkdir bin
    $ echo $PATH
  2. Download the repo script and make sure it is executable:
    $ curl http://android.git.kernel.org/repo >~/bin/repo
    $ chmod a+x ~/bin/repo
  3. Create an empty directory to hold your working files:
    $ mkdir mydroid
    $ cd mydroid
  4. Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
    $ repo init -u git://android.git.kernel.org/platform/manifest.git
  5. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account.
A successful initialization will end with a message such as
repo initialized in /mydroid


Your client directory should now contain a .repo directory where files such as the manifest will be kept.


What will my name and email be used for?

To use the Gerrit code-review tool,
you will need an email address that is connected with a registered Google account (which does not have to be a Gmail address). Make sure this is a live address at which you can receive messages. The real name that you provide here will show up in attributions for your code submissions.

What is a manifest file?

The Android source files are divided among a number of different repositories. A manifest file contains a mapping of where the files from these repositories will be placed within your working directory when you synchronize your files.


Getting the files

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ repo sync

For more about repo sync and other Repo commands, see Using Repo and Git.

The Android source files will be located in your working directory under their project names.


Building the code

To build the files, run make from within your working directory:
$ cd ~/mydroid
$ make

If your build fails, complaining about a missing "run-java-tool", try setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making. E.g.,

$ export ANDROID_JAVA_HOME=$JAVA_HOME

Using an IDE

Troubleshooting

ImportError: No module named readline

Mac users getting this should install Python 2.5.2.

Linux users that installed Python from source, make sure the dependencies for libreadline are installed, and rebuild Python.

What's next?

To learn about reporting an issue and searching previously reported issues, see Report bugs. For information about editing the files and uploading changes to the code-review server, see Contribute.

'old > Build Serv' 카테고리의 다른 글

adb driver setting for ubuntu  (0) 2010.03.12
Ubuntu Build Machine Install  (0) 2010.02.04
Posted by jazzlife
,

On windows:

If you’re developing on Windwos (32-bit only), you need to install the USB driver for adb:

1.  Download the driver ZIP file and unzip it.

2. Connect your Android device via USB. When the Found New Hardware Wizard appears, you’ll be asked if you’d like Windows Update to search for software, select No, not this time and click Next.

3. Select Install from a list or specified location and clieck Next.

4. Select Search for the best driver in these locations. Browse and select the unzipped file.

5. Click Finish. You’re all set.

On Ubuntu Linux

1.
Plug-in your device then exec command ‘lsusb’ then you will see the list of current usb devices

Bus 003 Device 023: ID 18d1:d00d

We will see a device is appeared when it plug-in and disappeared when it plug-out. That device is we wanted and take my environment as an example it is located at line 1, “Bus 003 Device 023: ID 18d1:d00d”, without device provider.

2. Login as root and create this file: /etc/udev/rules.d/50-android.rules

For Gusty/Hardy, edit the file to read:

SUBSYSTEM==”usb”, SYSFS(idVendor)==”18d1“, MODE=”0666″

For Dapper, edit the file to read:

SUBSYSTEM==”usb_device”, SYSFS(idVendor)==”18d1“, MODE=”0666″

P.S. the “18d1” is hard coded in android/kernel/drivers/usb/gadget/android_adb.c
#define DRIVER_VENDOR_ID

2. Nwx execute:

chmod a+rx /etc/udev/rules.d/50-android.rules

3. Restart udev to make the rule active.

 sudo /etc/init.d/udev restart

To construct the Android develop environment in Windows

October 28, 2008 at 3:33 pm | In android | Leave a Comment
Tags:
,

1. Create folder. Ex: C:\Android

2. Download Android SDK. Decompress it and put it in C:\Android\android_sdk

3. Download eclipse  3.4 (Ganymede). Decompress it and put it in C:\eclipse

4. Download and install Java SE Development Kit (JDK 5 or JDK 6).

5. Add the jre path to your path of environment variable. Ex: C:\Program Files\Java\jre1.6.0_05\bin

6. Install Android Eclipse Plugin ADT (Android Development Tools)

7. Installing the Eclipse Plugin (ADT)

  • Decompress it and put it in C:\Android\ADT\
  • Eclipse -> Help -> Software Updates… -> Add site -> Local -> select C:\Android\ADT\ -> OK -> OK
  • Press the check box of C:\Android\ADT and press install
  • Restart Eclipse.

8. Assign the path of Android SDK. Eclipse-> Window -> Preferences -> Android -> SDK Location -> C:\Android\android_sdk.

9. Now, you can create the Android project.

If Console display “Failed to get the adb version: Cannot run program “C:\Android\android_sdk\tools\adb.exe”: CreateProcess error=3″, you can ignore it.

'old > Build Serv' 카테고리의 다른 글

ubuntu android 설치  (0) 2010.03.12
Ubuntu Build Machine Install  (0) 2010.02.04
Posted by jazzlife
,

Vcard

old/sms_mms 2010. 3. 9. 21:02

'old > sms_mms' 카테고리의 다른 글

외부 app의 DB와 동기화를 위해서 감시하는 코드  (0) 2010.04.23
소프트키보드 설정  (0) 2010.03.30
Posted by jazzlife
,

 

JD - Java decompiler
The Java Decompiler project aims to develop tools in order to decompile and analyze Java 5 byte code and the later versions.
JD is Open Source and free to use.
Also available is JD-GUI, a standalone graphical utility that displays Java source codes of .class files, and JD-Eclipse, a plug-in for the Eclipse platform.


Jad
Jad, the fast JAva Decompiler, is a program that reads one or more Java class files and converts them into Java source files which can be compiled again.
Jad is a 100% pure C++ program and it generally works several times faster than decompilers written in Java. Jad doesn't use the Java runtime for its functioning, therefore no special setup is required (like changes to the CLASSPATH variable).
Jad is not open source but it is free to use.
Make sure to download the GUI interface, FrontEnd Plus .
On Windows, a file association with the .class extension is made so if you click on a class file then the decompiled is shown in FrontEnd Plus right away.
http://www.kpdus.com/jad.html
JAD is good but out-dated, the new class format introduced with JDK1.5 is not well supported.


JadClipse - .class 파일을 보기 위한 plugin
JadClipse is a plug-in that seamlessly integrates Jad (the fast Java decompiler) with Eclipse.
Normally, when opening a class file the Class File Viewer will show a brief API outline of the class. If you install this plug-in, however, the Class File Viewer will be replaced with the JadClipse Class File Viewer that shows the decompiled source of the class.


JarPlug - .jar 파일을 보기 위한 plugin
By default, the support for viewing and editing JAR file in Eclipse is very limited.
With JarPlug, it is possible delete or update items stored in a JAR.

1.    Jad/JadClipse - .class의 소스를 보기 위한 plugin
아래에서 다운받아 eclipse plugin폴더에 넣은 후 이클립스 재시작 합니다.
http://cid-b8b46a1f85e98311.office.live.com/embedicon.aspx/dev^_tools/net.sf.jadclipse^_3.3.0.jar

https://skydrive.live.com/embed?cid=B8B46A1F85E98311&resid=B8B46A1F85E98311%211008&authkey=AI3LoboZjnX3xQ4

https://skydrive.live.com/embed?cid=B8B46A1F85E98311&resid=B8B46A1F85E98311%211009&authkey=AG9vJkmVsin3H7s

Eclipse가 설치된 폴더에 넣고 후 경로를 window-preference-java-JadClipse 항목에 기입하면 됩니다.
http://cid-b8b46a1f85e98311.office.live.com/embedicon.aspx/dev^_tools/jad158g.win.zip

설치가 완료되었다면 window-preference-general-editors-file association을 선택하여 .class 파일의 associated editors JadClipse Class File View default 세팅합니다.

2.    JarPlug - .jar의 소스를 보기 위한 plugin
Install New Software에서 아래 주소를 입력하여 모두 설치한다.
http://www.simontuffs.com/jar-plug

 

'etc' 카테고리의 다른 글

eclipse 언어 변경  (0) 2010.04.09
익스플로러로 ftp 접속  (0) 2010.04.07
xml 등 강좌  (0) 2010.02.19
이클립스 단축키 정리  (0) 2010.02.11
JAVA, Eclipse 참고 사이트  (0) 2010.02.09
Posted by jazzlife
,
    @SuppressWarnings("unused")
    private static void log(String logMsg) {
        Thread current = Thread.currentThread();
        long tid = current.getId();
        StackTraceElement[] stack = current.getStackTrace();
        String methodName = stack[3].getMethodName();
        // Prepend current thread ID and name of calling method to the message.
        logMsg = "[" + tid + "] [" + methodName + "] " + logMsg;
        Log.d(TAG, logMsg);
    }

'old > Prepare' 카테고리의 다른 글

이클립스 한글언어팩  (0) 2010.03.15
R.drawable image preview  (0) 2010.03.03
Framework 소스 변경 필요 시  (0) 2010.03.02
시스템 유틸 삭제 및 유저데이터 삭제  (0) 2010.03.02
Sim Card Check 해제  (0) 2010.03.02
Posted by jazzlife
,

'old > Prepare' 카테고리의 다른 글

이클립스 한글언어팩  (0) 2010.03.15
DDMS에서 로그를 확인하기 위한 메서드  (0) 2010.03.04
Framework 소스 변경 필요 시  (0) 2010.03.02
시스템 유틸 삭제 및 유저데이터 삭제  (0) 2010.03.02
Sim Card Check 해제  (0) 2010.03.02
Posted by jazzlife
,

전체소스를 Linux에서 풀어보시면

build_target.sh 라는 파일이 있습니다.

이것을 실행하시면 build가 진행이 되고

/out/target/product/alohag 밑에 boot.img, system.img, userdata.img가 생성이 됩니다.

이것을 Fastboot mode에서 download.bat 파일을 실행하면

폰으로 다운로드가 되고 새로운 System.img파일이 올라가게 됩니다.

*download.bat파일은 tool이라는 폴더에 공유해 드렸습니다.

 

/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates

빌드를 하시고 이쪽을 열어 보시면 classes.jar 파일이 생성 되어 있습니다.

이것을 eclipse에서 사용하는 것 입니다.

Posted by jazzlife
,

Usb 케이블 연결하고 power를 눌러 폰을 켜고(현재 버전이 불안정 해서 그런 것이고  나중에는 폰켜고 나서도 될 거에요)USB Debugging”이 켜져 있는지 확인하고

도스창 띄워놓고

 

adb remount

adb shell

#cd system/app

#rm Mms.apk

#exit

 

이렇게 실행 하시면 Mms app가 폰에서 삭제 됩니다.

이렇게 하고 나서 fastboot mode에서

 

fastboot.exe -w

 

이렇게 입력하시면 User data가 지워 집니다.

다시 폰을 부팅하시고 eclipse에서 빌드된 Mms apk를 폰에 올리시면 됩니다.

'old > Prepare' 카테고리의 다른 글

R.drawable image preview  (0) 2010.03.03
Framework 소스 변경 필요 시  (0) 2010.03.02
Sim Card Check 해제  (0) 2010.03.02
프로젝트 실행 & 이클립스 디버깅 & 단말 세팅  (0) 2010.02.11
이클립스 개발환경 & 사용법  (0) 2010.02.11
Posted by jazzlife
,