1// dummy notifications for demos
2// for anandx@google.com by dsandler@google.com
3
4package com.android.example.notificationshowcase;
5
6import android.app.Activity;
7import android.app.NotificationManager;
8import android.content.ComponentName;
9import android.content.Context;
10import android.content.Intent;
11import android.net.Uri;
12import android.os.Bundle;
13import android.support.v4.app.NotificationManagerCompat;
14import android.view.View;
15import android.widget.Button;
16
17public 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