在另一个包没有意图过滤器启动服务 [英] Start service in another package without Intent filter

查看:217
本文介绍了在另一个包没有意图过滤器启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有开始在另一个包中定义一个Android服务没有在清单文件中使用意向过滤器标签的方式?出于某种原因,我将无法更新包含Service应用程序的清单文件。

Is there a way to start an Android Service defined in another package without using the Intent-Filter tag in the manifest file? For some reason I would not be able to update the manifest file of the app that contains the Service.

推荐答案

如果您知道确切的包名和服务名,您可以创建,一个意图。该服务还需要在其他清单虽然声明。

If you know the exact package name and service name you can create an Intent with that. The service still needs to be declared in the other manifest though.

Intent intent = new Intent();
intent.setClassName("com.example.otherapplication", "com.example.otherapplication.ServiceName");
startService(intent);

这篇关于在另一个包没有意图过滤器启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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