读书人

Intent跟Broadcast面对面

发布时间: 2012-07-28 12:25:13 作者: rapoo

Intent和Broadcast面对面

?

第4章? Intent和Broadcast面对面

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
????? package="YOUR_PACKAGE_NAME"
????? android:versionCode="1"
????? android:versionName="1.0">
??? <application android:icon="@drawable/icon"android:label="@string/app_name">
??????? <activityandroid:name="YOUR_ACTIVITY "
?????????????????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="BroadcastRecTest">
??????? <intent-filter>

?????????????</intent-filter>
??? </receiver>


发送SMS/MMS:
???? Intent it =new Intent(Intent.ACTION_VIEW);
???? it.putExtra("sms_body","android开发网欢迎您");
???? it.setType("vnd.android-dir/mms-sms");
???? startActivity(it);?

发送短信:
???? Uri uri =Uri.parse("smsto:10086");
???? Intent it = newIntent(Intent.ACTION_SENDTO, uri);
???? it.putExtra("sms_body","10086"); //正文为10086
???? startActivity(it);?

发送彩信:
???? Uri uri = Uri.parse("YOUR_CONTENT_PATH");//该Uri根据实际情况修改,external代表外部存储即sdcard
???? Intent it = newIntent(Intent.ACTION_SEND);
???? it.putExtra("sms_body","android123.com.cn");
???? it.putExtra(Intent.EXTRA_STREAM,uri);
???? it.setType("image/png");
???? startActivity(it);
发送Email:

?

读书人网 >移动开发

热点推荐