1 // dummy notifications for demos 2 // for anandx (at) google.com by dsandler (at) google.com 3 4 package com.android.example.notificationshowcase; 5 6 import android.app.Activity; 7 import android.app.NotificationManager; 8 import android.content.ComponentName; 9 import android.content.Context; 10 import android.content.Intent; 11 import android.net.Uri; 12 import android.os.Bundle; 13 import android.support.v4.app.NotificationManagerCompat; 14 import android.view.View; 15 import android.widget.Button; 16 17 public class NotificationShowcaseActivity extends Activity { 18 private static final String TAG = "NotificationShowcase"; 19 @Override 20 public void onCreate(Bundle savedInstanceState) { 21 super.onCreate(savedInstanceState); 22 setContentView(R.layout.main); 23 } 24 25 @Override 26 protected void onResume() { 27 super.onResume(); 28 Button disableBtn = (Button) findViewById(R.id.disable); 29 NotificationManagerCompat noMa = NotificationManagerCompat.from(this); 30 if(noMa.areNotificationsEnabled()) { 31 disableBtn.setText(R.string.disable_button_label); 32 } else { 33 disableBtn.setText(R.string.enable_button_label); 34 } 35 } 36 37 public void doPost(View v) { 38 Intent intent = new Intent(NotificationService.ACTION_CREATE); 39 intent.setComponent(new ComponentName(this, NotificationService.class)); 40 startService(intent); 41 } 42 43 public void doRemove(View v) { 44 Intent intent = new Intent(NotificationService.ACTION_DESTROY); 45 intent.setComponent(new ComponentName(this, NotificationService.class)); 46 startService(intent); 47 } 48 49 public void doPrefs(View v) { 50 Intent intent = new Intent(); 51 intent.setComponent(new ComponentName(this, SettingsActivity.class)); 52 startActivity(intent); 53 } 54 55 public void doDisable(View v) { 56 startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, 57 Uri.parse("package:com.android.example.notificationshowcase"))); 58 } 59 } 60