无界面应用(就一个后台服务),开始怎么启动这个服务?只能等开机广播吗?有木有适合启动service的广播,讨论讨论? 更多 分享到: 相关主题推荐: 界面 应用 android 相关帖子推荐: [*] Android 后台应用 无界面,怎么启动service
完全没有界面,那应该是 AndroidManifest.xml 文件里一个activity也没有声明.
没有声明activity就肯定没有一个响应如下配置的intent:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
没有这个配置应用程序就没有入口.
没有入口就无法启动应用程序进程.
应用程序进程都起不来,service肯定也起不来.
=========================================
所以要启动一个完全没有界面的apk包中的service,那只能由其他进程来启动了.
比如如下service:
<manifest xmlns:android="package="no.ui.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
......
<service
android:enabled="true"
android:name="no.ui.app.i_am_service"
android:process="i_am_service" >
<intent-filter>
<action android:name="no.ui.app.start_service"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
</application>
</manifest>
安装了这个apk后,在另一个apk的某个地方调用
就可以启动这个service了.
startService(new Intent("no.ui.app.start_service"));
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-07-31
有系统权限可以通过广播启动 没有的话只能靠其他程序启动 4.0后自己永远起不来的
第2个回答 2015-08-12
你好,可以直接用adb shell am startservice -n com.xxx.xxx/.MyService
第3个回答 2015-08-24
直接start
Server s=new Server();
startServer(s);
Server s=new Server();
startServer(s);
第4个回答 推荐于2017-12-16
有系统权限可以通过广播启动 没有的话只能靠其他程序启动 4.0后自己永远起不来的 查看原帖>>
求采纳本回答被提问者采纳
求采纳本回答被提问者采纳