Android: How to detect other apps when they're

Asked 2 years ago, Updated 2 years ago, 139 views

Hi. I'm currently trying to develop an app that prevents users from using certain apps without passwords. Here's the scenario...

I know how to do everything else, but I don't know what to do with number two. and broadcasting intents, etc., or "android.intent.action" in my trial project.If you look at MAIN", it's not my appI can't find a way to detect it when it's done.

Is there anyone who can help me? Is it right to look for new apps to broadcast Intent, or should I check the system logs to see new intents, or should I do some coding itself?

Even if it's not a definite answer, I think any hint will help a lot. Thank you in advance.

android android-intent broadcastreceiver

2022-09-22 12:02

1 Answers

I think it would be better to check the output using logcat.

I found one thing in common among the programs:

android.permission.READ_LOGS

He asked for the same authority as above. This means that all similar programs use the log above. The program starts and then the program (app protector) that the questioner wants starts and appears at the top.

Try writing the code below:

try
    {
        Process mLogcatProc = null;
        BufferedReader reader = null;
        mLogcatProc = Runtime.getRuntime().exec(new String[]{"logcat", "-d"});

        reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));

        String line;
        final StringBuilder log = new StringBuilder();
        String separator = System.getProperty("line.separator"); 

        while ((line = reader.readLine()) != null)
        {
            log.append(line);
            log.append(separator);
        }
        String w = log.toString();
        Toast.makeText(getApplicationContext(),w, Toast.LENGTH_LONG).show();
    }
    catch (Exception e) 
    {
        Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }

And don't forget to give the money to the Manifest file.


2022-09-22 12:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.