이클립스에서 프로젝트를 불러와서 사용하다 보면,,,


Unable to resolve target 'Google Inc.:Google APIs:XX'

라는 에러를 자주 보게 된다....


이거 엄첨 아주 엄청 짜증나게 된다..


이러한 경우는 해당 버전을 업데이트 하지 않나서 나타나는 경우에 이러한 에러가 나타 나게 된다...


<<해결법>>


프로젝트 마우스 오른쪽 클릭 -> Properties -> Android 


Project Target 체크를 해준다.!!!


그럼,,,, 해결~!~



'IT 공부 > 안드로이드' 카테고리의 다른 글

Failed to install on device timeout ERROR  (2) 2012.10.27
Intent 활용 예시들  (0) 2012.10.26
android service  (1) 2012.03.12
안드로이드 한글 깨짐 현상 수정법  (2) 2012.03.10
android intent 여러값넘기기  (1) 2012.03.08

과제를 다시 리팩토링 하던 도중 갑자기 생겨버린 에러 -_-;;


한참을 고민해서 수정했습니다. 


수정방법은 이와 같습니다. 이것은 디바이스에 업로드 할때 시간에 필요한데 


시간이 부족하여 생기는 에러이다. 그래서 이와 같은 방법으로 수정을 하면 된다


Preference -> Android -> DDMS 




ADB connection time out(int)의 임의의 수를 올려준다.

// 웹페이지 띄우기

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);  



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

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

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



// 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);  

// 패키지명은 어플리케이션의 전체 패키지명을 입력해야 합니다.



// 마켓 어플리케이션 상세 화면

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

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

startActivity(it);

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



// 구글 검색

Intent intent = new Intent();

intent.setAction(Intent.ACTION_WEB_SEARCH);

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

startActivity(intent);


http://theeye.pe.kr/entry/a-tip-of-android-intent-with-simple-examples

<아이군님의 블로그에서 퍼온글입니다>

Service는 background에서 처리를 계속할 수 있는 클래스이다.
Service는 기본적으로 activity를 가지지 않는다.

서비스를 구현하기 위한 3가지 절차
-- Service 클래스를 확장한 새로운 클래스 정의
-- Manifest file에 Service 선언 추가
-- App에서 Service 실행



1. 서비스를 실행하는 클래스 - 타이머를 이용한 반복 처리.


public class MyService extends Service implements Runnable {

    // 시작 ID
    private int mStartId;
    // 서비스에 대한 스레드에 연결된 Handler. 타이머 이용한 반복 처리시 사용.
    private Handler mHandler;
    // 서비스 동작여부 flag
    private boolean mRunning;
    // 타이머 설정 (2초)
    private static final int TIMER_PERIOD = 2 * 1000; 
    private static final int COUNT = 10;
    private int mCounter;


    // 서비스를 생성할 때 호출
    public void onCreate() {
        Log.e("MyService", "Service Created.");
        super.onCreate();
        mHandler = new Handler();
        mRunning = false;
    }


    // 서비스 시작할 때 호출. background에서의 처리가 시작됨.
    // startId : 서비스 시작요구 id. stopSelf에서 종료할 때 사용. 

     //onStart는 여러번 호출될 수 있기 때문에 식별자로 사용.

    public void onStart(Intent intent, int startId) {
        Log.e("MyService", "Service startId = " + startId);
        super.onStart(intent, startId);
        mStartId = startId;
        mCounter = COUNT;

        // 동작중이 아니면 run 메소드를 일정 시간 후에 시작
        if (!mRunning) {
              // this : 서비스 처리의 본체인 run 메소드. Runnable 인터페이스를 구현 필요.
              // postDelayed : 일정시간마다 메소드 호출
              mHandler.postDelayed(this, TIMER_PERIOD);
              mRunning = true;
        }
    }

 

    // 서비스의 종료시 호출
    public void onDestroy() {
        // onDestroy가 호출되어 서비스가 종료되어도
        // postDelayed는 바로 정지되지 않고 다음 번 run 메소드를 호출.
        mRunning = false;
        super.onDestroy();
    }


    // 서비스 처리
    public void run() {
        if (!mRunning) {
            // 서비스 종료 요청이 들어온 경우 그냥 종료
            Log.e("MyService", "run after destory");
            return;
        } else if (--mCounter <= 0) {
            // 지정한 횟수 실행하면 스스로 종료
            Log.e("MyService", "stop Service id = "+mStartId);
            stopSelf(mStartId);
        } else {
            // 다음 작업을 다시 요구
            Log.e("MyService", "mCounter : " + mCounter);
            mHandler.postDelayed(this, TIMER_PERIOD);
        }
    }

    // 원격 메소드 호출을 위해 사용
    // 메서드 호출을 제공하지 않으면 null을 반환
    public IBinder onBind(Intent intent) {
        return null;
    }
}




2. 서비스 실행, 종료를 사용자가 요청하는 클래스


// 서비스 시작과 종료를 요구하는 Activity
public class MyServiceActivity extends Activity {

    ComponentName mService;    // 시작 서비스의 이름
    TextView mTextView;              // 서비스 상태 표시


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        mTextView = (TextView)findViewById(R.id.text_view);
       
        Button start = (Button)findViewById(R.id.start_button);
        start.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v) {
                startHelloService();
            }});
       
        Button stop = (Button)findViewById(R.id.stop_button);
        stop.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v) {
                stopHelloService();
            }});
    }


    // 서비스 시작 요청
    private void startHelloService() {
        mService = startService(new Intent(this, MyService.class));
        mTextView.append(mService.toShortString()+" started.\n");
    }

 

    // 실행한 서비스 중지 요청

    private void stopHelloService() {
        if (mService == null) {
            mTextView.append("No requested service.\n");
            return;
        }
       
        Intent i = new Intent();
        i.setComponent(mService);
        if (stopService(i))
            mTextView.append(mService.toShortString()+" is stopped.\n");
        else
            mTextView.append(mService.toShortString()+" is alrady stopped.\n");
    }
}



<service android:enabled="true" android:name=".MyServic"></service>

'IT 공부 > 안드로이드' 카테고리의 다른 글

Failed to install on device timeout ERROR  (2) 2012.10.27
Intent 활용 예시들  (0) 2012.10.26
안드로이드 한글 깨짐 현상 수정법  (2) 2012.03.10
android intent 여러값넘기기  (1) 2012.03.08
android animation 반복  (1) 2012.03.05


안드로이드 개발하다보면 import해서 쓰는 경우가 허다한데

이때 파일을 불러왔을때 이상한 단어로 깨져서 오게 된다

이때 수정법을 말하면,,

Window → Preferences → 왼쪽 메뉴 General → Content Types

 

Java Source File 혹은 한글 깨짐과 관련된 항목을 선택하시고 

Default encoding: euc-kr 로 바꿔서 한번 해보세요

 


Intent intent = new Intent(this, IntentCallee.class);

intent.putExtra("name",edittext.getText().toString());  //값을 intent에 name value 형식으로 할당한다.

startActivity(intent);

 

받는 부분에서

Intent intent = getIntent(); // getIntent()는 현재 자신을 호출했던 intent를 반환 한다.

String name = intent.getExtras().get("name").toString(); //get을 통해 name을 호출하고 toString으로 문자열을 만든다.

그런다음 TextView에 받아온 문자열을 넣어준다

textview.setText(name);

 

참고 : http://cafe.naver.com/pykoraclejava/104

 

추가 :

intent로 DTO 객체를 넘기는 방법이 있다.

우선 넘기는 방법은

Person person = new Person("a",10,"20");

intent.putExtra("person", person);

 

다만 조건은 Person객체에 직렬화가 되어 있어야한다.

직렬화 하는 방법은 implements Serializable 만 해주면 자동으로 직렬화가 된다.

 

받는 부분에서는

Person ps = (Person)intent.getSerializableExtra("person");

 

해주면 된다.

 

추가2:

intent로 DTO객체를 List에 실어서 넘기는 방법이 있다.

우선 넘기는 방법은

제네럴 리스트를 사용하여

ArrayList<Person> list = new ArrayList<Person>();

list.add(new Person("a",22,"aa"));

list.add(new Person("b",23,"bb"));

intent.putExtra("list",list);

이런식으로 넘기면 되고

 

받는 부분에서는

ArrayList<Person> list = (ArrayList<Person>) intent.getSerializableExtra("list");

이런식으로 받으면 된다.



<<추가소스>>
android:repeatMode="reverse"
android:repeatCount="infinite"
액티비티 간에 애니메이션을 주어 부드럽게 화면이 전환된다....

-------소스--------
startActivity();
    overridePendingTransition(R.anim.fade, R.anim.hold);
   finish();


<<fade.xml>>
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toAlpha="1.0" />



<<hold.xml>>
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromXDelta="0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toXDelta="0" />

'IT 공부 > 안드로이드' 카테고리의 다른 글

android intent 여러값넘기기  (1) 2012.03.08
android animation 반복  (1) 2012.03.05
안드로이드 예제  (2) 2012.03.04
android 종료  (1) 2012.03.03
android back key Event  (2) 2012.03.03

'IT 공부 > 안드로이드' 카테고리의 다른 글

android animation 반복  (1) 2012.03.05
android Activity Animation effect (안드로이드 액티비티간에 애니메이션)  (1) 2012.03.05
android 종료  (1) 2012.03.03
android back key Event  (2) 2012.03.03
android Thread Counting  (2) 2012.03.03

android 종료하기 위해서는 2가지 방법이 있다.

Activity창을 나가는 방법으로써는

1.
  android.os.Process.killProcess(android.os.Process.myPid());
2.
  System.exit(0);

이렇게 있고,

실행중인 Activity창을 다끌려고 하면
moveTaskToBack(true);
   android.os.Process.killProcess(android.os.Process.myPid());

이렇게 하면 된다.

+ Recent posts