1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.example.notificationshowcase;
18 
19 import android.app.Activity;
20 import android.app.NotificationManager;
21 import android.app.PendingIntent;
22 import android.content.Context;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.view.View;
26 
27 public class FullScreenActivity extends Activity {
28     private static final String TAG = "NotificationShowcase";
29 
30     public static final String EXTRA_ID = "id";
31 
32     @Override
onCreate(Bundle savedInstanceState)33     public void onCreate(Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35         setContentView(R.layout.full_screen);
36         final Intent intent = getIntent();
37         if (intent != null && intent.hasExtra(EXTRA_ID)) {
38             final int id = intent.getIntExtra(EXTRA_ID, -1);
39             if (id >= 0) {
40                 NotificationManager noMa =
41                         (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
42                 noMa.cancel(NotificationService.NOTIFICATION_ID + id);
43             }
44         }
45     }
46 
dismiss(View v)47     public void dismiss(View v) {
48         finish();
49     }
50 
getPendingIntent(Context context, int id)51     public static PendingIntent getPendingIntent(Context context, int id) {
52         Intent fullScreenIntent = new Intent(context, FullScreenActivity.class);
53         fullScreenIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
54 
55         fullScreenIntent.putExtra(EXTRA_ID, id);
56         PendingIntent pi = PendingIntent.getActivity(
57                 context, 22, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
58         return pi;
59     }
60 }
61