일부 연구를 위해 갤럭시 기어 용 앱을 쓰고 있습니다. 전화에서 오는 알림을 "잡아"기어에 내 자신의 알림을 던져야합니다.갤럭시 기어 알림 방법
요점은 다음과 같습니다. 어떻게 기어 자체에 통보합니까?
다음 코드는 갤럭시 S4에 근무하지만, "onCreated()"와 "onStartCommand 방법에 아래의 코드를하는 사람들과 내가 서비스를 만들어
... 갤럭시 기어에 통지를 포기하지 않습니다() " MyNotificationSvc.java
private void doJob() throws InterruptedException{
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!");
Intent mainIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(mainIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(123, mBuilder.build());
stopSelf();
}
내가 시작"StartSvc "클릭 한"버튼을 때, "MyNotificationSvc을. 클릭하면 앱이 "최소화"되고 10 초 후에 알림이 표시됩니다. 주의 사항 : 스마트 폰에서 가져온 것이 아닙니다! Galaxy Gear 자체에서 알림이 표시되어야합니다.
public void startSvc(View v){
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
startService(new Intent(this, MyNotificationSvc.class));
}
그리고
너무 감사 AppManifest.xml
<service android:name=".MyNotificationSvc"></service>
이 라인을 추가 :
"StartSvc"- 버튼의 onclick을-방법입니다!