Example usage for android.content Intent ACTION_PACKAGE_REMOVED

List of usage examples for android.content Intent ACTION_PACKAGE_REMOVED

Introduction

In this page you can find the example usage for android.content Intent ACTION_PACKAGE_REMOVED.

Prototype

String ACTION_PACKAGE_REMOVED

To view the source code for android.content Intent ACTION_PACKAGE_REMOVED.

Click Source Link

Document

Broadcast Action: An existing application package has been removed from the device.

Usage

From source file:org.deviceconnect.android.manager.DConnectMessageService.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    super.onStartCommand(intent, flags, startId);
    if (intent == null) {
        mLogger.warning("intent is null.");
        return START_STICKY;
    }/*from   w  ww  .j  a va2s .c  o m*/

    if (!mRunningFlag) {
        return START_STICKY;
    }

    String action = intent.getAction();
    if (action == null) {
        mLogger.warning("action is null.");
        return START_STICKY;
    }

    String scheme = intent.getScheme();
    if (SCHEME_LAUNCH.equals(scheme)) {
        String key = intent.getStringExtra(IntentDConnectMessage.EXTRA_KEY);
        String origin = intent.getStringExtra(IntentDConnectMessage.EXTRA_ORIGIN);
        if (key != null && !TextUtils.isEmpty(origin)) {
            mHmacManager.updateKey(origin, key);
        }
        return START_STICKY;
    }

    if (checkAction(action)) {
        onRequestReceive(intent);
    } else if (IntentDConnectMessage.ACTION_RESPONSE.equals(action)) {
        onResponseReceive(intent);
    } else if (IntentDConnectMessage.ACTION_EVENT.equals(action)) {
        onEventReceive(intent);
    } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
        mPluginMgr.checkAndAddDevicePlugin(intent);
    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
        mPluginMgr.checkAndRemoveDevicePlugin(intent);
    }

    return START_STICKY;
}

From source file:me.piebridge.prevent.framework.SystemReceiver.java

private void handlePackage(Intent intent, String action) {
    String packageName = PackageUtils.getPackageName(intent);
    if (Intent.ACTION_PACKAGE_RESTARTED.equals(action)) {
        handlePackageRestarted("PACKAGE_RESTARTED", packageName);
    } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
        onPackageAdded(intent);//from w  w w  . ja v  a  2  s. co  m
    } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
        onPackageRemoved(intent);
    }
}

From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java

@Override
public void onResume() {
    super.onResume();
    updateSources();/* ww  w  .  j a  v a  2  s. c o  m*/

    IntentFilter packageChangeIntentFilter = new IntentFilter();
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageChangeIntentFilter.addDataScheme("package");
    getActivity().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter);
}

From source file:com.mappn.gfan.ui.HomeTabActivity.java

private void registerReceivers() {
    IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(mNetworkReceiver, filter);
    IntentFilter intentClickFilter = new IntentFilter(Constants.BROADCAST_CLICK_INTENT);
    registerReceiver(mIntentClickReceiver, intentClickFilter);

    IntentFilter appFilter = new IntentFilter();
    appFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    appFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    appFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    appFilter.addDataScheme("package");
    registerReceiver(mInstallReceiver, appFilter);

    IntentFilter updatefilter = new IntentFilter();
    updatefilter.addAction(Constants.BROADCAST_FORCE_EXIT);
    updatefilter.addAction(Constants.BROADCAST_REMIND_LATTER);
    updatefilter.addAction(Constants.BROADCAST_DOWNLOAD_OPT);
    updatefilter.addAction(Constants.BROADCAST_DOWNLOAD);
    registerReceiver(mUpdateReceiver, updatefilter);
}

From source file:com.cleanwiz.applock.service.LockService.java

public void registerApplicationReceiver() {
    IntentFilter packageIntentFilter = new IntentFilter();
    IntentFilter eventIntentFilter = new IntentFilter();
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    eventIntentFilter.addAction(Intent.ACTION_TIME_TICK);
    eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageIntentFilter.addDataScheme("package");
    getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter);
    getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter);
    IntentFilter filter = new IntentFilter();
    filter.addAction(LOCK_SERVICE_LASTTIME);
    filter.addAction(LOCK_SERVICE_LEAVEAMENT);
    filter.addAction(LOCK_SERVICE_LEAVERTIME);
    filter.addAction(LOCK_SERVICE_LOCKSTATE);

    lastUnlockTimeSeconds = 0;/*  ww w  .  ja  v  a 2 s.c o m*/
    allowedLeaveAment = application.getAllowedLeaveAment();
    leaverTime = application.getLeaverTime();
    lockState = application.getAppLockState();
    registerReceiver(new ServiceReceiver(), filter);
}

From source file:com.fastbootmobile.encore.service.PlaybackService.java

/**
 * Called when the service is created//from   www  .ja va 2  s .  co  m
 */
@Override
public void onCreate() {
    super.onCreate();
    mListenLogger = new ListenLogger(this);
    mPrefetcher = new Prefetcher(this);

    mCommandsHandlerThread = new HandlerThread("PlaybackServiceCommandsHandler");
    mCommandsHandlerThread.start();

    mCommandsHandler = new CommandHandler(this, mCommandsHandlerThread);

    // Register package manager to receive updates
    mPacManReceiver = new PacManReceiver();
    IntentFilter pacManFilter = new IntentFilter();
    pacManFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    pacManFilter.addDataScheme("package");
    registerReceiver(mPacManReceiver, pacManFilter);

    // Really Google, I'd love to use your new APIs... But they're not working. If you use
    // the new Lollipop metadata system, you lose Bluetooth AVRCP since the Bluetooth
    // package still use the old RemoteController system.
    /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    mRemoteMetadata = new RemoteMetadataManagerv21(this);
    } else*/ {
        mRemoteMetadata = new RemoteMetadataManager(this);
    }

    ProviderAggregator.getDefault().addUpdateCallback(this);

    // Native playback initialization
    mNativeHub = new NativeHub(getApplicationContext());
    mNativeSink = new NativeAudioSink();
    mNativeHub.setSinkPointer(mNativeSink.getPlayer().getHandle());
    mNativeHub.setOnAudioWrittenListener(this);
    mNativeHub.onStart();

    mDSPProcessor = new DSPProcessor(this);
    mDSPProcessor.restoreChain(this);

    // Plugins initialization
    PluginsLookup.getDefault().initialize(getApplicationContext());
    PluginsLookup.getDefault().registerProviderListener(this);

    List<ProviderConnection> connections = PluginsLookup.getDefault().getAvailableProviders();
    for (ProviderConnection conn : connections) {
        if (conn.getBinder(false) != null) {
            assignProviderAudioSocket(conn);
        } else {
            Log.w(TAG, "Cannot assign audio socket to " + conn.getIdentifier() + ", binder is null");
        }
    }

    // Setup
    mIsStopping = false;

    // Bind to all provider
    List<ProviderConnection> providers = PluginsLookup.getDefault().getAvailableProviders();
    for (ProviderConnection pc : providers) {
        try {
            IMusicProvider binder = pc.getBinder(false);
            if (binder != null) {
                binder.registerCallback(mProviderCallback);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Cannot register callback", e);
        }
    }

    // Register AutoMix manager
    mCallbacks.add(AutoMixManager.getDefault());

    // Setup notification system
    mNotification = new ServiceNotification(this);
    mNotification.setOnNotificationChangedListener(new ServiceNotification.NotificationChangedListener() {
        @Override
        public void onNotificationChanged(ServiceNotification notification) {
            NotificationManagerCompat nmc = NotificationManagerCompat.from(PlaybackService.this);
            if (mIsForeground) {
                notification.notify(nmc);
                mIsForeground = true;
            } else {
                notification.notify(PlaybackService.this);
            }

            BitmapDrawable albumArt = notification.getAlbumArt();
            mRemoteMetadata.setAlbumArt(albumArt);
        }
    });

    // Setup lockscreen remote controls
    mRemoteMetadata.setup();

    // Setup playback wakelock (but don't acquire it yet)
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "OmniMusicPlayback");

    // Restore preferences
    SharedPreferences prefs = getSharedPreferences(SERVICE_SHARED_PREFS, MODE_PRIVATE);
    mRepeatMode = prefs.getBoolean(PREF_KEY_REPEAT, false);
    mShuffleMode = prefs.getBoolean(PREF_KEY_SHUFFLE, false);

    // TODO: Use callbacks
    // Restore playback queue after one second - we have multiple things to wait here:
    //  - The callbacks of the main app's UI
    //  - The providers connecting
    //  - The providers ready to send us data
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            SharedPreferences queuePrefs = getSharedPreferences(QUEUE_SHARED_PREFS, MODE_PRIVATE);
            mPlaybackQueue.restore(queuePrefs);
            mCurrentTrack = queuePrefs.getInt("current", -1);
            mCurrentTrackLoaded = false;
            mNotification.setHasNext(mPlaybackQueue.size() > 1 || (mPlaybackQueue.size() > 0 && mRepeatMode));
        }
    }, 1000);
}

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

@Override
public void onResume() {
    super.onResume();

    getActivity().registerReceiver(mUserBackgrounding, new IntentFilter(Intent.ACTION_USER_BACKGROUND));
    IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addDataScheme("package");
    getActivity().registerReceiver(mPackageObserver, packageFilter);

    mAppListChanged = false;//from www.j a v  a  2  s .  c o  m
    if (mAppLoadingTask == null || mAppLoadingTask.getStatus() == AsyncTask.Status.FINISHED) {
        mAppLoadingTask = new AppLoadingTask().execute();
    }
}

From source file:org.mariotaku.twidere.app.TwidereApplication.java

@Override
public void onCreate() {
    sInstance = this;
    if (BuildConfig.DEBUG) {
        StrictModeUtils.detectAllVmPolicy();
    }/*  w ww .  j  a v  a2 s  .c o  m*/
    final SharedPreferences preferences = getSharedPreferences();
    resetTheme(preferences);
    super.onCreate();

    mProfileImageViewViewProcessor = new ProfileImageViewViewProcessor();
    mFontFamilyTagProcessor = new FontFamilyTagProcessor();

    ATE.registerViewProcessor(TabPagerIndicator.class, new TabPagerIndicatorViewProcessor());
    ATE.registerViewProcessor(FloatingActionButton.class, new FloatingActionButtonViewProcessor());
    ATE.registerViewProcessor(ActionBarContextView.class, new ActionBarContextViewViewProcessor());
    ATE.registerViewProcessor(SwipeRefreshLayout.class, new SwipeRefreshLayoutViewProcessor());
    ATE.registerViewProcessor(TimelineContentTextView.class, new TimelineContentTextViewViewProcessor());
    ATE.registerViewProcessor(TextView.class, new TextViewViewProcessor());
    ATE.registerViewProcessor(ImageView.class, new ImageViewViewProcessor());
    ATE.registerViewProcessor(MaterialEditText.class, new MaterialEditTextViewProcessor());
    ATE.registerViewProcessor(ProgressWheel.class, new ProgressWheelViewProcessor());
    ATE.registerViewProcessor(ProfileImageView.class, mProfileImageViewViewProcessor);
    ATE.registerTagProcessor(OptimalLinkColorTagProcessor.TAG, new OptimalLinkColorTagProcessor());
    ATE.registerTagProcessor(FontFamilyTagProcessor.TAG, mFontFamilyTagProcessor);
    ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR,
            new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR));
    ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED,
            new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED));
    ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED,
            new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED));
    ATE.registerTagProcessor(ThemedMultiValueSwitch.PREFIX_TINT, new ThemedMultiValueSwitch.TintTagProcessor());

    mProfileImageViewViewProcessor.setStyle(Utils.getProfileImageStyle(preferences));
    mFontFamilyTagProcessor.setFontFamily(ThemeUtils.getThemeFontFamily(preferences));

    final int themeColor = preferences.getInt(KEY_THEME_COLOR,
            ContextCompat.getColor(this, R.color.branding_color));
    if (!ATE.config(this, VALUE_THEME_NAME_LIGHT).isConfigured()) {
        //noinspection WrongConstant
        ATE.config(this, VALUE_THEME_NAME_LIGHT).primaryColor(themeColor)
                .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK)).coloredActionBar(true)
                .coloredStatusBar(true).commit();
    }
    if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) {
        ATE.config(this, VALUE_THEME_NAME_DARK)
                .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE)).coloredActionBar(false)
                .coloredStatusBar(true).statusBarColor(Color.BLACK).commit();
    }
    if (!ATE.config(this, null).isConfigured()) {
        ATE.config(this, null).accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE))
                .coloredActionBar(false).coloredStatusBar(false).commit();
    }
    initializeAsyncTask();
    initDebugMode();
    initBugReport();
    mHandler = new Handler();

    final PackageManager pm = getPackageManager();
    final ComponentName main = new ComponentName(this, MainActivity.class);
    final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class);
    final boolean mainDisabled = pm
            .getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean main2Disabled = pm
            .getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean noEntry = mainDisabled && main2Disabled;
    if (noEntry) {
        pm.setComponentEnabledSetting(main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    } else if (!mainDisabled) {
        pm.setComponentEnabledSetting(main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
    if (!Utils.isComposeNowSupported(this)) {
        final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class);
        pm.setComponentEnabledSetting(assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }

    migrateUsageStatisticsPreferences();
    Utils.startRefreshServiceIfNeeded(this);

    DependencyHolder holder = DependencyHolder.get(this);
    registerActivityLifecycleCallbacks(holder.getActivityTracker());

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
            final String[] packages = getPackageManager().getPackagesForUid(uid);
            DependencyHolder holder = DependencyHolder.get(context);
            final ExternalThemeManager manager = holder.getExternalThemeManager();
            if (ArrayUtils.contains(packages, manager.getEmojiPackageName())) {
                manager.reloadEmojiPreferences();
            }
        }
    }, packageFilter);
}

From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java

@Override
public void onResume() {
    super.onResume();
    updateSources();/*  ww w .  j a va  2 s  .c om*/

    IntentFilter packageChangeIntentFilter = new IntentFilter();
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageChangeIntentFilter.addDataScheme("package");
    getContext().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter);
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final int userId = Util.getUserId(Process.myUid());

    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;/*ww  w  .  j a  va  2s  .  c o m*/

    // Set layout
    setContentView(R.layout.restrictionlist);

    // Get arguments
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }

    int uid = extras.getInt(cUid);
    String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null);
    String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null);

    // Get app info
    mAppInfo = new ApplicationInfoEx(this, uid);
    if (mAppInfo.getPackageName().size() == 0) {
        finish();
        return;
    }

    // Set title
    setTitle(String.format("%s - %s", getString(R.string.app_name),
            TextUtils.join(", ", mAppInfo.getApplicationName())));

    // Handle info click
    ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo);
    imgInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Packages can be selected on the web site
            Util.viewUri(ActivityApp.this,
                    Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s",
                            mAppInfo.getPackageName().get(0))));
        }
    });

    // Display app name
    TextView tvAppName = (TextView) findViewById(R.id.tvApp);
    tvAppName.setText(mAppInfo.toString());

    // Background color
    if (mAppInfo.isSystem()) {
        LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo);
        llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
    }

    // Display app icon
    final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon);
    imgIcon.setImageDrawable(mAppInfo.getIcon(this));

    // Handle icon click
    imgIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openContextMenu(imgIcon);
        }
    });

    // Display on-demand state
    final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand);
    if (PrivacyManager.isApplication(mAppInfo.getUid())
            && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) {
        boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                false);
        imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());

        imgCbOnDemand.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(),
                        PrivacyManager.cSettingOnDemand, false);
                PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                        Boolean.toString(ondemand));
                imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());
                if (mPrivacyListAdapter != null)
                    mPrivacyListAdapter.notifyDataSetChanged();
            }
        });
    } else
        imgCbOnDemand.setVisibility(View.GONE);

    // Display restriction state
    swEnabled = (Switch) findViewById(R.id.swEnable);
    swEnabled.setChecked(
            PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true));
    swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted,
                    Boolean.toString(isChecked));
            if (mPrivacyListAdapter != null)
                mPrivacyListAdapter.notifyDataSetChanged();
            imgCbOnDemand.setEnabled(isChecked);
        }
    });
    imgCbOnDemand.setEnabled(swEnabled.isChecked());

    // Add context menu to icon
    registerForContextMenu(imgIcon);

    // Check if internet access
    if (!mAppInfo.hasInternet(this)) {
        ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet);
        imgInternet.setVisibility(View.INVISIBLE);
    }

    // Check if frozen
    if (!mAppInfo.isFrozen(this)) {
        ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen);
        imgFrozen.setVisibility(View.INVISIBLE);
    }

    // Display version
    TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
    tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this)));

    // Display package name
    TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName);
    tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName()));

    // Fill privacy list view adapter
    final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction);
    lvRestriction.setGroupIndicator(null);
    mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName,
            methodName);
    lvRestriction.setAdapter(mPrivacyListAdapter);
    if (restrictionName != null) {
        int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values())
                .indexOf(restrictionName);
        lvRestriction.expandGroup(groupPosition);
        lvRestriction.setSelectedGroup(groupPosition);
        if (methodName != null) {
            int childPosition = PrivacyManager.getHooks(restrictionName)
                    .indexOf(new Hook(restrictionName, methodName));
            lvRestriction.setSelectedChild(groupPosition, childPosition, true);
        }
    }

    // Listen for package add/remove
    IntentFilter iff = new IntentFilter();
    iff.addAction(Intent.ACTION_PACKAGE_REMOVED);
    iff.addDataScheme("package");
    registerReceiver(mPackageChangeReceiver, iff);
    mPackageChangeReceiverRegistered = true;

    // Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // Tutorial
    if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) {
        ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
        ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
    }
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewParent parent = view.getParent();
            while (!parent.getClass().equals(ScrollView.class))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString());
        }
    };
    ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener);
    ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener);

    // Process actions
    if (extras.containsKey(cAction)) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(mAppInfo.getUid());
        if (extras.getInt(cAction) == cActionClear)
            optionClear();
        else if (extras.getInt(cAction) == cActionSettings)
            optionSettings();
    }

    // Annotate
    Meta.annotate(this);
}