定义广播,创建一个类继承
BroadcastReceiver,在清单文件中注册具体例题如VidoPlayer 360云盘http://yunpan.cn/cZNcQw3cf3Spb 访问密码 9d90的
清单文件
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
manifest
xmlns:android
=
"http://schemas.android.com/apk/res/android"
package
=
"com.sung.vidoplayer"
android:versionCode
=
"1"
android:versionName
=
"1.0"
>
<
uses-sdk
android:minSdkVersion
=
"9"
android:targetSdkVersion
=
"9"
/>
<!-- -设置全屏 -->
<!-- 设置横屏 -->
<
uses-permission
android:name
=
"android.permission.RECEIVE_SMS"
/>
<
application
android:allowBackup
=
"true"
android:icon
=
"@drawable/ic_launcher"
android:label
=
"@string/app_name"
android:theme
=
"@style/AppTheme"
>
<
activity
android:theme
=
"@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation
=
"landscape"
android:name
=
"com.sung.vidoplayer.MainActivity"
android:label
=
"@string/app_name"
>
<
intent-filter
>
<
action
android:name
=
"android.intent.action.MAIN"
/>
<
category
android:name
=
"android.intent.category.LAUNCHER"
/>
</
intent-filter
>
</
activity
>
<!-- 设置广播接收者关心短信到来 -->
< receiver android:name ="com.sung.vidoplayer.SmsReceiver" >
< intent-filter>
< action android:name ="android.provider.Telephony.SMS_RECEIVED" />
</ intent-filter>
</ receiver>
</
application
>
</
manifest
>
public
class
SmsReceiver
extends
BroadcastReceiver {
@Override
public
void
onReceive(Context context, Intent intent) {
//
TODO
Auto-generated method stub
Toast. makeText(context,
"你有短信息来了"
, 5000).show();
}
}