PID的发送的意图的过程 [英] Pid for the process that sent an intent

查看:226
本文介绍了PID的发送的意图的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发现,给我发了一个意图的进程的进程ID或包名称。我不想把进程ID或包的名称以一个额外的(如一些其他的问题都问),因为我不想让欺骗。在code我用的是:

I am trying to discover the process id or package name of the process that sent me an intent. I don't want to put the process id or package name in an extra (as some other questions have asked) since I don't want to allow spoofing. The code I used is:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_secure_file_share);
    ...   

    Intent intent = getIntent();

    if (intent != null)
    {
        // get the caller
        String callingPackage = getAppNameByPID(getApplicationContext(),
               Binder.getCallingPid());
    ....
    }
 }

其中, getAppNameByPID 翻译的PID的包名。问题是, Binder.getCallingPid()总是返回收件人的PID(不是调用程序的)。

Where getAppNameByPID translates the PID to the package name. The problem is that Binder.getCallingPid() always returns the recipient's PID (not the caller's).

你怎么调用者的PID?

How do you get the caller's PID?

推荐答案

看看

http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html

这篇关于PID的发送的意图的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆