/* 建构Intent对象,指定开启对象为mService1服务 */
Intent i = new Intent( EX06_04.this, mService1.class );
/* 设定新TASK的方式 */
i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
/* 以startService方法启动Intent */
Intent i = new Intent( EX06_04.this, mService1.class );
/* 设定新TASK的方式 */
i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
/* 以startService方法启动Intent */
startService(i);
/* 构造Intent对象,指定欲关闭的对象为mService1服务 */
Intent i = new Intent( EX06_04.this, mService1.class );
/* 以stopService方法关闭Intent */
stopService(i);
启动与停止Android服务
本文介绍了如何使用Intent在Android应用中启动与停止服务。通过设置Intent的Flags并使用startService和stopService方法来实现服务的管理和控制。
4285

被折叠的 条评论
为什么被折叠?



