기본 콘텐츠로 건너뛰기

[android] 자바스크립트에서 함수 호출 및 자바스크립트 호출하기

[자바스크립트에서 안드로이드 함수 호출] 1. 인터페이스 클래스 생성 targetSdkVersion 을 17이상이면  @JavascriptInterface를 꼭 추가해야한다. 추가하지 않으면 함수가 동작하지 않는다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public   class  WebAppInterface  {        Context mContext;         /** Instantiate the interface and set the context */        WebAppInterface(Context c)   {                mContext  =  c;         }         /** Show a toast from the web page */         @JavascriptInterface         public   void   showToast ( String  toast)   {                Toast.makeText(mContext,  toast,  Toast.LENGTH_SHORT) .show( ...

[android] 폰과 태블릿 구분

Colored By Color Scripter ™ 1 2 3 4 5 6 7 8 9 10 boolean  isTablet  ( )   {                   int  portrait_width_pixel=Math.min( this .getResources( ) .getDisplayMetrics( ) .widthPixels,   this .getResources( ) .getDisplayMetrics( ) .heightPixels) ;                 int  dots_per_virtual_inch= this .getResources( ) .getDisplayMetrics( ) .densityDpi;                 float  virutal_width_inch=portrait_width_pixel/dots_per_virtual_inch;                 if   (virutal_width_inch  < =  2)   {                         return   false ;                 }   else   {                 ...

[android] textview에 이미지 넣기

setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom) : 글씨의 왼쪽, 상단, 오른쪽, 아래에 이미지 추가  setCompoundDrawablePadding (int pad) : 이미지와 글씨 사이의 간격 설정 1 2 3 4 TextView txtEvent = (TextView)convertView.findViewById(R.id.cell_event); txtEvent.setCompoundDrawablesWithIntrinsicBounds(R.drawable.event, 0, 0, 0); txtEvent.setCompoundDrawablePadding(10); txtEvent.setText( "이벤트합니다." );

[android] 네트워크 상태가 변경 될 때 마다 실시간 확인 방법. (BroadcastReceiver 사용)

네트워크가 변경되었을 때 실시간으로 앱에서 하고 싶은 동작을 할 수 있다. [AndroidManifest.xml] activity와 동등한 단계에 추가. Colored By Color Scripter ™ 1 2 3 4 5 <receiver android:name  =   "appNetwork" >                 <intent-filter>                         <action android:name= "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED" / >                 < /intent-filter> < /receiver> [appNetwork.java] Colored By Color Scripter ™ 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 31 32 33 34 35 36 37 38 39 40 public   class  appNetwork  extends  BroadcastReceiver  {         private  Activity activity;       ...