| |
---|
| | private List<Notification> notifications =null; |
---|
| | private CosmosLocation LOC = new CosmosLocation(); |
---|
| | private double leftLat,leftLon,rightLat,rightLon; //ここに計算予定 |
---|
| | private int count = 0; |
---|
| | private NotificationManager notificationManager; |
---|
| | |
---|
| | public CosmosBackgroundService() { |
---|
| | super("CosmosBackgroundService"); |
---|
| | Log.d(TAG, "Constructor"); |
---|
| |
---|
| | super.onCreate(); |
---|
| | context = getApplicationContext(); |
---|
| | // LocationManager インスタンス生成 |
---|
| | locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); |
---|
| | notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); |
---|
| | int importance = NotificationManager.IMPORTANCE_HIGH; |
---|
| | NotificationChannel mChannel = new NotificationChannel("cosmos", "cosmosChannel", importance); |
---|
| | notificationManager.createNotificationChannel(mChannel); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public void onStart(@Nullable Intent intent, int startId) { |
---|
| |
---|
| | Log.d(TAG, "lon:" + location.getLongitude()); |
---|
| | |
---|
| | updateAreaInformation(location); |
---|
| | this.notifications=searchNotifications(cosmos,location); |
---|
| | sendNotifications(this, notifications); |
---|
| | |
---|
| | |
---|
| | } |
---|
| | |
---|
| | private void sendNotifications(CosmosBackgroundService cosmosBackgroundService, List<Notification> notifications) { |
---|
| | int notificationId = 1; |
---|
| | // MainActivity→broadcastreseiver(?)に変更 |
---|
| | // Intent intent = new Intent(cosmosBackgroundService, MainActivity.class); |
---|
| | // 以下二行はボタンについてだよ |
---|
| | // PendingIntent pendingIntent = PendingIntent.getActivity(cosmosBackgroundService, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); |
---|
| | // android.app.Notification.Action action = new android.app.Notification.Action(R.drawable.notification_icon, "ボタンだよ", pendingIntent); |
---|
| | |
---|
| | android.app.Notification notification = new android.app.Notification.Builder(cosmosBackgroundService) |
---|
| | .setContentTitle("通知タイトル") |
---|
| | .setContentText("通知ないよう") |
---|
| | .setSmallIcon(R.drawable.icon_no) |
---|
| | .setChannelId("cosmos") |
---|
| | // .setGroup("") |
---|
| | // .addAction(action) |
---|
| | .build(); |
---|
| | notificationManager.notify(notificationId, notification); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public void onStatusChanged(String provider, int status, Bundle extras) { |
---|
| |
---|
| | |