简体   繁体   English

如何通过Android中的我的应用程序检测用户单击/启动了哪个应用程序

[英]How to detect which application is clicked/launched by the user through my application in android

我需要知道是否有接收方可以检测用户通过我自己的应用程序单击或启动了哪个应用程序

i think you can use logcat and analyze it's output. 我认为您可以使用logcat并分析其输出。

in all similar programs i found this permission : 在所有类似的程序中,我都获得了此许可:

android.permission.READ_LOGS

that mean all of them use it. 这意味着所有人都使用它。 but it seems the program starts and after that our program (app protector) will start and bring front. 但似乎程序启动了,之后我们的程序(应用保护程序)就会启动并取得领先。

use below code : 使用以下代码:

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 do not forget it s permission on android manifest. 并且不要忘记它对android manifest的许可。

UPDATED: find the which application is launched, by Tracking the Logcat . 更新:通过跟踪Logcat查找启动了哪个应用程序。 Just Track on ActivityManager tag with info -I log. 只需跟踪带有信息-I日志的ActivityManager标签即可。

From adb shell Command is, 从adb shell命令开始,

adb logcat ActivityManager:I *:S

From your application code, 根据您的应用程序代码,

logcat ActivityManager:I *:S

And in Logcat you can find a line something like, 在Logcat中,您可以找到类似以下内容的行:

I/ActivityManager(  585): Starting activity: Intent { action=android.intent.action...}

When any application will launched. 什么时候将启动任何应用程序。

It is logcat output that shows that the message relates to priority level "I" and tag "ActivityManager": logcat输出显示该消息与优先级“ I”和标签“ ActivityManager”有关:

Just add permission in your Application's manifest file, 只需在应用程序的清单文件中添加权限,

android.permission.READ_LOGS android.permission.READ_LOGS

自android 4.1起不推荐使用,应用只能使用android.permission.READ_LOGS访问其自己的日志

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何终止从我当前在android中启动的应用程序? - How to terminate an application which is launched from my current application in android? 如何在我的应用程序中检测Android选择的布局? - How can I detect which layout is selected by Android in my application? 我怎么知道那个特定的应用程序。 在android中通过我的应用程序启动 - how can I know that certain app. in android is launched through my Application 具有两个入口点的Android应用程序。 如何知道用户在应用程序对象的onCreate()上单击了哪个 - Android application with two entry points. How to know which is clicked by user on onCreate() of application object 找到哪个应用程序启动了我的Activity - Find which application launched my Activity 如何返回启动我的应用程序的应用程序 - How to come back to the Application that launched my application 如何检测用户点击完成或在Android中的应用程序之后打开已经以编程方式安装 - how to detect if user clicked done or open after application in android has been installed programmatically 如何使我的android应用程序在启动时启动然后隐藏 - How to make my android application launched in the boot and then hidden 如何检测哪个应用程序在Android中设置为默认值? - How to detect which application is set as default in android? 如何使用Firebase通过我的Android应用程序保持用户持久登录 - How to keep a user persistent logged in through my Android application with Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM