aboutsummaryrefslogtreecommitdiff
path: root/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java')
-rw-r--r--NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
index 8d1a2fc..2d0d09b 100644
--- a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
+++ b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java
@@ -8,8 +8,11 @@ import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
+import android.support.v4.app.NotificationManagerCompat;
import android.view.View;
+import android.widget.Button;
public class NotificationShowcaseActivity extends Activity {
private static final String TAG = "NotificationShowcase";
@@ -19,6 +22,18 @@ public class NotificationShowcaseActivity extends Activity {
setContentView(R.layout.main);
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Button disableBtn = (Button) findViewById(R.id.disable);
+ NotificationManagerCompat noMa = NotificationManagerCompat.from(this);
+ if(noMa.areNotificationsEnabled()) {
+ disableBtn.setText(R.string.disable_button_label);
+ } else {
+ disableBtn.setText(R.string.enable_button_label);
+ }
+ }
+
public void doPost(View v) {
Intent intent = new Intent(NotificationService.ACTION_CREATE);
intent.setComponent(new ComponentName(this, NotificationService.class));
@@ -36,4 +51,9 @@ public class NotificationShowcaseActivity extends Activity {
intent.setComponent(new ComponentName(this, SettingsActivity.class));
startActivity(intent);
}
+
+ public void doDisable(View v) {
+ startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
+ Uri.parse("package:com.android.example.notificationshowcase")));
+ }
}