Question

I'm trying to create an application that will blacklist certain applications (based on user input) and will block these applications from launching by bringing the main (or some other part of my app) to the foreground when the blacklisted apps are detected in the foreground.

This will be similar to Smart App Protector, but with additional trigger conditions.

I have the service detecting the apps fine, but I'm having trouble getting the main activity to come to the front.

Any ideas? Thanks in advance.

Was it helpful?

Solution

Use this when you detect the blacklisted applicaton:

Intent startupIntent = new Intent(context, ActivityToLaunch.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(startupIntent);

OTHER TIPS

It's always a bad habit to bring your activity to the forground suddenly without notifications. We always recommend sending a notification via the notification manager and by clicking the notification message it runs your activity using Pending Intents. Does this meet your needs ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top