短信列表界面:
private void showMMSViewByPackagePath() {
Intent intent = new Intent();
intent.setClassName("com.android.mms",
"com.android.mms.ui.ConversationList");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
}
//这是Intent-Filter过滤方式,是通用的方式。
private void showMMSViewByIntentFilter() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("vnd.android-dir/mms-sms");
// 或改成亦可
// intent.setType("vnd.android.cursor.dir/mms");
startActivity(intent);
}
public static void startSystemActivity(Context context, String action,
Uri uri, String type) {
Intent intent = new Intent();
intent.setAction(action);
intent.setData(uri);
intent.setType(type);
context.startActivity(intent);
}
发送短信界面:
String type = "vnd.android-dir/mms-sms";
startSystemActivity(this,Intent.ACTION_VIEW,null,type);
短信列表界面:
String type = "vnd.android-dir/mms-sms";
startSystemActivity(this, Intent.ACTION_MAIN, null, type);
拨号盘界面:
startSystemActivity(this,Intent.ACTION_DIAL,null,null);
浏览器界面:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri content_url = Uri.parse("http://www.google.com");
intent.setData(content_url);
startActivity(intent);
启动系统的谷歌浏览器:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName("com.android.chrome",
"com.google.android.apps.chrome.Main"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(ci);
Camera界面:
String action = "android.media.action.STILL_IMAGE_CAMERA";
startSystemActivity(this,action,null,null);
启动系统的Camera:
Intent ci = new Intent(Intent.ACTION_MAIN);
ci.addCategory(Intent.CATEGORY_LAUNCHER);
ci.setComponent(new ComponentName("com.intel.camera22", "com.intel.camera22.Camera"));
ci.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(ci);
Android Activity之间的跳转方式:
1.startActivity(Intent intent);
2.startActivityForResult(Intent intent, int requestCode);
作用:
在多个需要跳转的Activity存在时,通过方法onActivityResult(int requestCode, int requestCode, Intent intent),中的requestCode以明确是跳转至哪个Activity,具体操作如下:
eg:从From跳转至ToB和ToC
From:
if(条件){
Intent intent = new Intent(this, ToB.class);
startActivityForResult(serverIntent, REQUEST_CODE_01);//跳转至ToB
}else{
Intent intent = new Intent(this, ToC.class);
startActivityForResult(serverIntent, REQUEST_CODE_02);//跳转至ToC
}
public void onActivityResult(int requestCode, int resultCode, Intent data){
switch (requestCode) {
case REQUEST_CODE_01:
if(resultCode==Activity.RESULT_OK)
//do something
break;
case REQUEST_CODE_02:
//do something
break;
}
}
补充:
卸载程序:
Uri packageURI = Uri.parse("package:com.demo.CanavaCancel");
安装apk: