android-async-http 라이브러리 jar 파일을 추가해서 컴파일을 하려고하는데 File - Structure - Library들어가서 추가하고 컴파일 해도 계속 import 에러가 나더라..


그래서 구글링 해본결과 이런 답변을 찾음

http://stackoverflow.com/questions/16608135/android-studio-add-jar-as-library


1. /libs 폴더에 jar를 복사하고 

2. 해당 라이브러리를 사용하고자 하는 Module 밑의 build.gradle 파일을 열어서

dependencies {

    compile files('libs/android-support-v4.jar')

    compile files('libs/android-async-http-1.4.3.jar')

}


3. 그 후 Terminal 에서 프로젝트 루트 디렉토리로 간 후 

gradlew clean

명령을 실행해서 다시 빌드하면 깔끔하게 동작한다.

Posted by 모과이IT
,

http://croute.me/334

Posted by 모과이IT
,



        

       // 리니어레이아웃 params 속성을 생성한다.

       // 아래 코드는 width = match_PARENT, height = 0dip를 가정한것

       LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 

                 LinearLayout.LayoutParams.MATCH_PARENT, 0);

         

       // weight 비율을 80%로 해본다(예를든것)

        params.weight = 0.8f;


       // 기존에 비율을 수정한 LinearLayout의 핸들을 가져온다

        LinearLayout layout = (LinearLayout)findViewById(R.id.subLay_Body);


       // 그 속성을 setLayoutParams 함수를 이용해서 넣어준다.

        layout.setLayoutParams(params);


Posted by 모과이IT
,

http://angrytools.com/android/pixelcalc/

Posted by 모과이IT
,

출처 : http://androidexample.com/Custom_Dialog_-_Android_Example/index.php?view=article_discription&aid=88&aaid=111



File : res/layout/custom_dialog_main.xml

 

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
     
        <Button
            android:id="@+id/buttonClick"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Click To Show Custom Dialog" />
             
    </LinearLayout>

 

File : res/layout/dialog.xml

Used to create custom dialog layout.

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
 
    <ImageView
        android:id="@+id/imageDialog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="6dp" />

    <TextView
        android:id="@+id/textDialog"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="#FFF"
        android:layout_toRightOf="@+id/imageDialog"/>
 
     <Button
        android:id="@+id/declineButton"
        android:layout_width="100px"
        android:layout_height="wrap_content"
        android:text=" Submit "
        android:layout_marginTop="5dp"
        android:layout_marginRight="5dp"
        android:layout_below="@+id/textDialog"
        android:layout_toRightOf="@+id/imageDialog"
        />
     
</RelativeLayout>

 

File : src/CustomDialog.java

 

    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.TextView;
    import android.app.Activity;
    import android.app.Dialog;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    
    
    public class CustomDialog extends Activity {
    
        private Button buttonClick;
    
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            setContentView(R.layout.custom_dialog_main);
    
            buttonClick = (Button) findViewById(R.id.buttonClick);
    
            // add listener to button 
            buttonClick.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
    
                    // Create custom dialog object
                    final Dialog dialog = new Dialog(CustomDialog.this);
                    // Include dialog.xml file
                    dialog.setContentView(R.layout.dialog);
                    // Set dialog title
                    dialog.setTitle("Custom Dialog");
    
                    // set values for custom dialog components - text, image and button
                    TextView text = (TextView) dialog.findViewById(R.id.textDialog);
                    text.setText("Custom dialog Android example.");
                    ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog);
                    image.setImageResource(R.drawable.image0);
    
                    dialog.show();
                    
                    Button declineButton = (Button) dialog.findViewById(R.id.declineButton);
                    // if decline button is clicked, close the custom dialog
                    declineButton.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Close dialog
                            dialog.dismiss();
                        }
                    });
    
                    
                }
    
            });
    
        }
    
    }


Posted by 모과이IT
,

http://developer.android.com/guide/topics/media/index.html

'개발지식창고 > Android_Java' 카테고리의 다른 글

안드로이드 치수 변환사이트  (0) 2015.02.06
Custom Dialog  (0) 2015.02.05
구글플레이 마켓 앱등록 출시 하기  (0) 2014.12.31
Back 버튼 프로그램 종료 코드  (0) 2014.12.11
SHA1 key export command  (0) 2014.11.10
Posted by 모과이IT
,

  | 구글플레이 마켓에 앱등록 출시하기


구글플레이에 자신이 만든앱 등록하는 방법을 알아보겠습니다^^


먼저 등록하기 전에 준비할게 있는데요~

안드로이드 개발자 계정 등록하기, 등록할 애플리케이션 서명하기를 먼저 하셔야 해요.

해당 카테고리에 포스팅한 내용 참고하시면 될거 같아요.


위 준비가 완료 되었다면!

https://play.google.com/apps/publish 사이트에 개발자계정으로 로그인합니다.


등록되어있는 앱이 없다면 아래처럼 
"Google Play에 Android 앱을 출시" 하기 버튼이 보입니다.




버튼을 클릭해주세요~







기본 언어와 앱의 제목을 입력해주세요. 그리고 하단에 APK 업로드 버튼을 클릭하세요.







업로드 하려는 서명한 APK를 업로드 합니다.







 APK를 올렸다면 "스토어등록 정보"를 입력해줍니다.





스크린샷도 올려줍니다. 스크린샷은 최소2장에서 8장까지 입력이 가능합니다.








대표 고해상도 아이콘 이미지도 올려줍니다. 저는 512X512를 사용했습니다.

그리고 애플리케이션 유형을 애플리케이션으로 하시고

카테고리는 앱성격에 맞게 설정해줍니다.

콘첸츠 등급도 자신의 앱에 맞게 설정합니다. 저는 전체이용가로 설정했습니다.






앱 개발자의 정보를 입력합니다. 웹사이트랑 이메일이 필수네요. 전 블로그 주소를 입력하였습니다.

그리고 개인정보 보호정책을 체크합니다.







이제 가격 및 배포탭을 클릭하여 가격정보를 입력합니다.

저는 무료앱이니 무료를 클릭합니다.

그리고 배포 대상국가는 모든국가를 선택했습니다.








아래 쪽에 콘첸츠 가이드라인과 미국 수출법규도 필수항목이니 체크해줍니다.








이 모든작업이 완료되었다면 우측 상단에 콤보박스에서 출시하기를 클릭합니다.

그러면 약 2시간 이내로 마켓에 앱이 등록되게 됩니다^^




출처 : http://enews24.tistory.com/79

'개발지식창고 > Android_Java' 카테고리의 다른 글

Custom Dialog  (0) 2015.02.05
Android Multimeida API in Google developer site  (0) 2015.01.31
Back 버튼 프로그램 종료 코드  (0) 2014.12.11
SHA1 key export command  (0) 2014.11.10
Android용 Google+ 로그인  (0) 2014.11.02
Posted by 모과이IT
,


import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.KeyEvent;


public class MyFinance extends Activity {

....



 // Back-key 클릭시 프로그램 종료 코드
 public boolean onKeyDown(int keyCode, KeyEvent event){
  switch(keyCode){
  case KeyEvent.KEYCODE_BACK:
   String alertTitle = getResources().getString(R.string.app_name);

   new AlertDialog.Builder(MyFinance.this)
   .setTitle(alertTitle)
   .setMessage("종료하겠습니까?")
   .setPositiveButton("예", new DialogInterface.OnClickListener(){
    
    public void onClick(DialogInterface dialog, int which){
     moveTaskToBack(true); // 본Activity finish후 다른 Activity가 뜨는 걸 방지.
     finish();
     // android.os.Process.killProcess(android.os.Process.myPid()); 
     // -> 해당 어플의 프로세스를 강제 Kill시킨다.
    }    
   })
   .setNegativeButton("아니오", null)
   .show();
  }
   
  return true;
 }



....
}



출처 : http://tksssch29.tistory.com/entry/Back-key-%ED%81%B4%EB%A6%AD%EC%8B%9C-%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8-%EC%A2%85%EB%A3%8C-%EC%BD%94%EB%93%9C

Posted by 모과이IT
,

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v


C:\Users\IN>C:\Java\jdk1.7.0_67\jre\bin\keytool.exe -exportcert -alias androidde

bugkey -keystore c:\users\in\.android/debug.keystore -list -v


암호 : android


---


C:\Users\INC>"C:\Program Files\Java\jdk1.7.0_67\bin\keytool" -exportcert -alias

androiddebugkey -keystore c:\users\inc\.android\debug.keystore -list -v


[회사 PC]

SHA1: 6A:86:54:BD:C1:36:33:DF:70:2C:64:E1:2B:0D:B5:5C:21:35:18:3A


[회사 맥(윈도우)]

 SHA1: AD:E5:9A:80:28:23:C3:97:6B:DC:73:AF:AD:72:43:83:C0:94:3E:77

Posted by 모과이IT
,

사용자가 앱에 안전하게 로그인하도록 하고 더 강력한 참여형 사용 환경을 만듭니다. 또한 Google+ 로그인을 사용하면 로그인한 사용자가 대화형 소식을 만들어 자신의 친구에게 앱을 사용하도록 초대하도록 함으로써 앱에 대한 참여도를 높일 수 있습니다. 사용자를 Google과 연결함으로써, 사용자에게 이미 앱을 사용하고 있는 친구를 보여주는 신뢰할 만한 소셜 추천을 통해 Google Play에서의 앱 인지도를 빠른 시간 내에 제고할 수 있습니다.

Google+ 로그인 버튼은 사용자를 인증하고 OAuth 2.0 플로를 관리하여 Google API와의 통합을 간소화합니다. 앱이 대화형 소식을 만들고 활동을 관리하며 프로필 및 사용자 정보를 가져오려면 로그인이 필요합니다.

사용자는 언제든지 애플리케이션에 대한 액세스를 취소할 수 있습니다.

시작하기 전에

Google API 콘솔 프로젝트를 만들고 PlusClient 개체를 초기화해야 합니다.

앱에 Google+ 로그인 버튼 추가

  1. 애플리케이션의 레이아웃에 SignInButton을 추가합니다.

    <com.google.android.gms.common.SignInButton
       
    android:id="@+id/sign_in_button"
       
    android:layout_width="wrap_content"
       
    android:layout_height="wrap_content" />
  2. Activity.onCreate  핸들러에서 요청된 표시 활동으로 mPlusClient를 초기화합니다.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
       
    super.onCreate(savedInstanceState);
        mPlusClient
    = new PlusClient.Builder(this, this, this)
               
    .setVisibleActivities("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity")
               
    .build();
    }
  3. Android 활동에서 버튼의 OnClickListener를 등록하여 해당 버튼을 클릭할 때 사용자를 로그인 처리합니다.

    findViewById(R.id.sign_in_button).setOnClickListener(this);
  4. 사용자가 로그인 버튼을 클릭한 후에는 mConnectionResult에서 발생하는 연결 오류를 해결하기 시작해야 합니다. 발생 가능한 연결 오류에는 사용자에게 계정을 선택하라는 메시지 표시 및 앱에 대한 액세스 권한 부여가 있습니다.

    @Override
    public void onClick(View view) {
       
    if (view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
           
    if (mConnectionResult == null) {
                mConnectionProgressDialog
    .show();
           
    } else {
               
    try {
                    mConnectionResult
    .startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
               
    } catch (SendIntentException e) {
                   
    // 다시 연결을 시도합니다.
                    mConnectionResult
    = null;
                    mPlusClient
    .connect();
               
    }
           
    }
       
    }
    }
  5. 사용자가 성공적으로 로그인한 경우 onConnected 핸들러가 호출됩니다. 이 때 사용자의 계정 이름을 가져오거나 인증된 요청을 수행할 수 있습니다.

    @Override
    public void onConnected(Bundle connectionHint) {
        mConnectionProgressDialog
    .dismiss();
       
    Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
    }

사용자 로그아웃 처리

앱에 로그아웃 버튼을 추가할 수 있습니다. 앱에 로그아웃 버튼으로 사용할 버튼을 만듭니다. 버튼에 onClickListener를 첨부하고 PlusClient를 연결 해제할 onClick 메소드를 설정합니다.

    @Override
   
public void onClick(View view) {
       
if (view.getId() == R.id.sign_out_button) {
           
if (mPlusClient.isConnected()) {
                mPlusClient
.clearDefaultAccount();
                mPlusClient
.disconnect();
                mPlusClient
.connect();
           
}
           
return true;
       
}
   
}

이 코드는 앱에 연결된 모든 계정을 삭제합니다. 다시 로그인하려면 사용자는 자신의 계정을 다시 선택해야 합니다.

액세스 토큰 취소 및 앱 연결 해제

Google+ 개발자 정책의 약관을 준수하려면 Google 계정으로 로그인한 사용자에게 앱과의 연결을 해제할 수 있는 기능을 제공해야 합니다. 사용자가 자신의 계정을 삭제하는 경우 앱이 Google API에서 가져온 정보를 삭제해야 합니다.

다음 코드는 PlusClient.revokeAccessAndDisconnect 메소드 호출 및 onAccessRevoked 이벤트에 대한 응답의 간단한 예를 보여줍니다.

    // 연결을 해제하기 전에 clearDefaultAccount()를 실행합니다.
    mPlusClient
.clearDefaultAccount();

    mPlusClient
.revokeAccessAndDisconnect(new OnAccessRevokedListener() {
       
@Override
       
public void onAccessRevoked(ConnectionResult status) {
           
// 이제 mPlusClient가 연결 해제되었고 액세스가 취소되었습니다.
           
// 앱 로직을 실행하여 개발자 정책을 준수합니다.
       
}
   
});

onAccessRevoked 콜백에서 이벤트에 응답하고 앱 또는 백엔드 코드에서 모든 적합한 로직을 실행할 수 있습니다. 자세한 내용은 개발자 정책에서 삭제 규칙을 참조하세요.

로그인 버튼 맞춤설정

앱의 디자인과 어울리도록 맞춤 로그인 버튼을 디자인할 수 있습니다. com.google.android.gms.common.SignInButton 클래스는 색상 테마 및 버튼의 크기를 변경할 수 있는 기능을 제공합니다. 추가 맞춤설정이 필요한 경우, 맞춤 버튼을 정의할 수 있습니다.

  1. 브랜드 가이드라인을 검토하고 버튼에 사용할 아이콘 및 이미지를 다운로드합니다.

  2. 애플리케이션 레이아웃에 버튼을 추가합니다.

    <Button
       
    android:id="@+id/button"
       
    android:layout_width="wrap_content"
       
    android:layout_height="wrap_content"
       
    android:layout_centerHorizontal="true"
       
    android:text="@string/common_signin_button_text_long" />

다음 예는 SDK에서 현지화된 텍스트를 로드합니다. 또한 활동의 onCreate 메소드 내에서getString(com.google.android.gms.R.string.common_signin_button_text_long)을 사용하여 버튼 텍스트의 라벨을 가져올 수 있습니다. 로그인 버튼을 어떻게 구현하든 브랜드 가이드라인을 준수해야 합니다.

현지화

SDK는 com.google.android.gms.common.SignInButton 버튼에 사용할 현지화된 문자열을 제공하며 이러한 문자열은 앱 사용자에게 자동으로 제공됩니다. 전체 언어 목록을 보려는 경우, SDK에서 다음 디렉토리를 살펴볼 수 있습니다. <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib/res/ 해당 위치를 보면 values-<langcode>라는 이름의 디렉토리가 있습니다.


[출처]

https://developers.google.com/+/mobile/android/sign-in?hl=ko

 


Posted by 모과이IT
,