2014-10-13 12 views
0

저는 시계 모드에서 작동 중이지만 작동 중입니다. 360에 장착하면 상호 작용에 느리게 반응합니다.Android Wear가 화면을 깨우지 못합니다.

알림을받을 때 화면이 깨어나지만 손목을 돌려 시각을 볼 때가 아님을주의해야합니다.

내가 한 마지막 일은 doWork에서 코드를 CountDownRunner로 옮기는 것이 었습니다.

import android.app.Activity; 
import android.os.Bundle; 
import android.os.Handler; 
import android.text.format.Time; 
import android.support.wearable.view.WatchViewStub; 
import android.view.animation.Animation; 
import android.view.animation.LinearInterpolator; 
import android.view.animation.RotateAnimation; 
import android.widget.ImageView; 
import android.widget.TextView; 
import java.util.Date; 

public class ClockActivity extends Activity { 

private TextView mTextView; 
private Handler mHandler = new Handler(); 
private ImageView img; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_clock); 

    Runnable runnable = new CountDownRunner(); 
    Thread myThread = new Thread(runnable); 
    myThread.start(); 

    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); 
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { 
     @Override 
     public void onLayoutInflated(WatchViewStub stub) { 
      mTextView = (TextView) stub.findViewById(R.id.text); 
     } 
    }); 
} 

class CountDownRunner implements Runnable{ 
    public void run() { 
     while(!Thread.currentThread().isInterrupted()){ 
      try { 
       Date dt = new Date(); 
       int hours = dt.getHours(); 
       int minutes = dt.getMinutes(); 
       int seconds = dt.getSeconds(); 
       String curTime = hours + ":" + minutes + ":" + seconds; 

       img=(ImageView)findViewById(R.id.hand_second); 
       RotateAnimation rotateAnimation = new RotateAnimation((seconds-1)*6, seconds*6, 
         Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 
         0.5f); 

       rotateAnimation.setInterpolator(new LinearInterpolator()); 
       rotateAnimation.setDuration(1000); 
       rotateAnimation.setFillAfter(true); 

       img.startAnimation(rotateAnimation); 
       runOnUiThread(new Runnable() { 
        public void run() { 
         try{ 

         }catch (Exception e) { 

         } 
        } 
       }); 
       Thread.sleep(1000); 
      } catch (InterruptedException e) { 
       Thread.currentThread().interrupt(); 
      }catch(Exception e){ 
      } 
     } 
    } 
} 

} 

답변

1

당신은 당신의 착용 시간을 변경 Runnable를 구현하지해야합니다 다음은 내 코드입니다. BroadcastReceiver (Intent.ACTION_TIME_TICK, Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_TIME_CHANGED)을 사용하고 시간이 변경되면 "틱 (tick)"을 수신합니다 (배터리 전원 및 CPU 사용이 적음). 당신은 초를 관리 할 수 ​​http://www.binpress.com/tutorial/how-to-create-a-custom-android-wear-watch-face/120

그리고 마지막 팁 :

또한, 당신은 화면 상태 여기

가 Android Wear에 대한 시계 모드의 큰 exemple입니다 (화면 희미한는 등, 깨어 화면) 관리해야한다 웨어러블이 깨어있을 때 (예 : 포스트 데일리처럼 착용 가능하지만 웨어러블이 다시 절전 모드로 돌아갈 때 살해되어야 함)에만 watchface를 사용하십시오.

+0

그래서 나는 그것을 모두 업데이트했지만 이제는 초침을 다시 작동시키는 것 같습니다. 모든 것을 준비하고 실행할 때까지 나는 에뮤 테스트를 마쳤습니다. 코드를 확인 하시겠습니까? http://pastebin.com/RzmJ5vCW – JMP

+0

BroadcastReceiver 메서드를 사용하면 분만 변경 될 때만 updateUI() 메서드가 호출됩니다. 웨어러블 장치가 깨어 있지 않을 때 메모리 누수를 방지합니다. 웨어러블 스크린이 깨어날 때 실행 가능한 스크립트를 추가하여 초 애니메이션을 업데이트하고 웨어러블 스크린이 떨어지면이 실행 파일을 제거 할 수 있습니다. 화면이 꺼져있는 동안 초를 업데이트하면 많은 CPU를 사용하여 배터리를 많이 사용합니다.) – Nasc

관련 문제