首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android 自启动 靠山运行 发送短信

2012-09-02 
Android 自启动 后台运行 发送短信android本地后台服务示例在android编写Service入门中介绍了android的两

Android 自启动 后台运行 发送短信
android本地后台服务示例

在android编写Service入门中介绍了android的两种后台服务,本地和远程的。这里用本地服务做了一个模拟定时后台发短信的技术原型。

启动该示例应用的样子:





选择启动:



启动后,可看到ddms logcat日志:



这是操作:启动、停止和退出应用,显示的调试日志信息。模拟后台服务每5秒钟发送一次短信信息。

主要代码,后台服务SmsService:

    <?xml version=”1.0″ encoding=”utf-8″?>    <manifest xmlns:android=”http://schemas.android.com/apk/res/android”        package=”com.easymorse” android:versionCode=”1″ android:versionName=”1.0″>        <application android:icon=”@drawable/icon” android:label=”@string/app_name”>            <activity android:name=”.SmsServiceOptions” android:label=”@string/app_name”>                <intent-filter>                    <action android:name=”android.intent.action.MAIN” />                    <category android:name=”android.intent.category.LAUNCHER” />                </intent-filter>            </activity>            <service android:name=”.SmsService”>                <intent-filter>                    <action android:name=”com.easymorse.SmsService”></action>                </intent-filter>            </service>        </application>        <uses-sdk android:minSdkVersion=”3″ />    </manifest> 
1 楼 cdn_mn_mm 2011-09-21   什么时候调用service的onDestroy方法呢 2 楼 ming_fanglin 2011-09-22   stopService 时

热点排行