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 17package com.android.example.notificationshowcase; 18 19import android.app.Activity; 20import android.app.NotificationManager; 21import android.app.PendingIntent; 22import android.content.Context; 23import android.content.Intent; 24import android.os.Bundle; 25import android.view.View; 26 27public class FullScreenActivity extends Activity { 28 private static final String TAG = "NotificationShowcase"; 29 30 public static final String EXTRA_ID = "id"; 31 32 @Override 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 47 public void dismiss(View v) { 48 finish(); 49 } 50 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