ACTION_FACTORY_TEST android.intent.action.FACTORY_TEST 工厂测试入口点
------------------------------------布局文件----------------------------------------------------------
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="wrap_content"
android:orientation="vertical" >
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="Android中常用系统Intent" />
----------------------------Activity代码--------------------------------------------------------
public class MainActivity extends Activity implements OnClickListener {
private Button callBtn;
private Button smsBtn;
private Button emailBtn;
private Button browseBtn;
private Button searchBtn;
private Button installBtn;
private Button unInstallBtn;
private Button mediaBtn;
private Button picBtn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initViewsById();
initListeners();
}
private void initViewsById() {
callBtn = (Button) findViewById(R.id.intent_call_btn);
smsBtn = (Button) findViewById(R.id.intent_sms_btn);
emailBtn = (Button) findViewById(R.id.intent_email_btn);
browseBtn = (Button) findViewById(R.id.intent_net_btn);
picBtn = (Button) findViewById(R.id.intent_pic_btn);
installBtn = (Button) findViewById(R.id.intent_install_btn);
unInstallBtn = (Button) findViewById(R.id.intent_unstall_btn);
mediaBtn = (Button) findViewById(R.id.intent_media_btn);
searchBtn = (Button) findViewById(R.id.intent_search_btn);
}
private void initListeners() {
callBtn.setOnClickListener(this);
smsBtn.setOnClickListener(this);
emailBtn.setOnClickListener(this);
browseBtn.setOnClickListener(this);
picBtn.setOnClickListener(this);
installBtn.setOnClickListener(this);
unInstallBtn.setOnClickListener(this);
mediaBtn.setOnClickListener(this);
searchBtn.setOnClickListener(this);
}
/**浏览器 */
private void netBrowse() {
/**地址*/
Uri uri = Uri.parse("http://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
/**视频 */
private void playMedia() {
/**uri*/
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
/**搜索 */
private void search() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY, "android");
startActivity(intent);
}
/**拨打电话 */
private void callTelphone() {
/**电话号码 */
Uri uri = Uri.parse("tel:10086");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
}
/**发短信Activity */
private void sendSms() {
Uri uri = Uri.parse("smsto:10086");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(intent);
}
/**发送图片(彩信) */
@SuppressLint("SdCardPath")
private void sendPicSms() {
/**图片位置*/
Uri imguri = Uri.parse("/mnt/sdcard/abc.png");
Intent intent = new Intent(Intent.ACTION_SEND);
/**图片流数据*/
intent.putExtra(Intent.EXTRA_STREAM, imguri);
/**指定类型*/
intent.setType("image/png");
startActivity(Intent.createChooser(intent, "Send Image To:"));
}
/**发邮件 */
private void sendEmail() {
Intent intent = new Intent(Intent.ACTION_SEND);
/**收件人*/
String[] to = { "[email protected]" };
intent.putExtra(Intent.EXTRA_EMAIL, to);
/** 抄送*/
String[] cc = { "[email protected]" };
intent.putExtra(Intent.EXTRA_CC, cc);
/**邮件主题*/
intent.putExtra(Intent.EXTRA_SUBJECT, "朋友,您好!");
/**邮件内容*/
intent.putExtra(Intent.EXTRA_TEXT, "好多的内容呀........");
/**类型/格式*/
intent.setType("message/rfc822");
startActivity(Intent.createChooser(intent, "请选择客户端邮箱!"));
}
/**安装应用 */
private void installSotf() {
/**地址*/
Intent intent = new Intent(Intent.ACTION_VIEW);
/**指定apk文件路径*/
intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/tutu.apk")), "application/vnd.android.package-archive");
startActivity(intent);
}
/**卸载应用程序 */
private void uninstallSoft() {
Uri uri = Uri.fromParts("package", "tutu.ch05", null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.intent_call_btn:
callTelphone();
break;
case R.id.intent_sms_btn:
sendSms();
break;
case R.id.intent_email_btn:
sendEmail();
break;
case R.id.intent_pic_btn:
sendPicSms();
break;
case R.id.intent_net_btn:
netBrowse();
break;
case R.id.intent_search_btn:
search();
break;
case R.id.intent_install_btn:
installSotf();
break;
case R.id.intent_unstall_btn:
uninstallSoft();
break;
case R.id.intent_media_btn:
playMedia();
break;
}
}
}
-------------------------------------------相应的权限------------------------------------------------------