简体   繁体   English

以编程方式从其他应用程序关闭本机应用程序

[英]Programmatically close a native application from another application

Basically, what I want to do is to close another app not created by me from my app. 基本上,我想要做的是关闭我的应用程序中不是由我创建的另一个应用程序。 I haven't been able to find a solution but have learned that this is something many critizise as being a bad solution in general. 我一直无法找到解决方案,但已经了解到这一点很多都被批评为一般来说是一个糟糕的解决方案。

I do believe I have a good reason. 我相信我有充分的理由。 What I want to do is to have an app that can recieve a file via PUSH OPP from another device that doesn't have an app installed on it. 我想要做的是有一个应用程序可以通过PUSH OPP从没有安装应用程序的其他设备接收文件。 To be able to do this I have to disable the host-device's PUSH OPP application. 为了能够做到这一点,我必须禁用主机设备的PUSH OPP应用程序。 I have to do this since I need to take over the default channel (12) for pushing files from the OS so that I have controll over the file-sending from the client. 我必须这样做,因为我需要接管默认通道(12)以从OS推送文件,以便我可以控制从客户端发送文件。 I can't use another channel since I can't have an app installed on the client and thus can't make it push the file via another channel. 我无法使用其他频道,因为我无法在客户端上安装应用程序,因此无法通过其他频道推送该文件。 I know this probably is very bad practice but the device with the application will only be used for this specific application. 我知道这可能是非常糟糕的做法,但带有应用程序的设备将仅用于此特定应用程序。

One way that seems to work is to manually disable the system's PUSH OPP application but this creates a hazzle when the user should install and use the app. 一种似乎有效的方法是手动禁用系统的PUSH OPP应用程序,但这会在用户安装和使用应用程序时产生hazzle。 They have to: 1. Install the app. 他们必须:1。安装应用程序。 2. Every time they start the device they have to go into running applications and disable the standard PUSH OPP. 2.每次启动设备时,他们都必须运行应用程序并禁用标准PUSH OPP。 3. Run the app. 3.运行应用程序。

If I would be able to send a quit-command through my app to the native PUSH OPP app the default channel (12) would be freed up for me to use without the user having to go through step 2 every time. 如果我能够通过我的应用程序向本机PUSH OPP应用程序发送退出命令,则可以释放默认频道(12)供我使用,而无需用户每次都必须通过步骤2。 Is this even possible to do without root-access? 这甚至可以在没有root访问的情况下进行吗?

in your code, youcan use system(“kill pid”); 在你的代码中,你可以使用system(“kill pid”); get pid from /proc 从/ proc得到pid

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM