1.跳转到应用安装界面
(apk需在sd卡中,如在手机内存则出现安装包解析异常解决请参考)
<span style="font-size:18px;">File file = new File(Environment.getExternalStorageDirectory(), "2016608recyclerview.apk");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
//Uri.parse("file://"+apkFile.getAbsolutePath()) 以前的写法
intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
//启动系统中的安装界面Activity 获取结果
startActivityForResult(intent, 250);</span>
2.跳转到应用卸载界面
<span style="font-size:18px;"><span style="font-size:24px;">Intent uninstallIntent = new Intent();
uninstallIntent.setAction(Intent.ACTION_DELETE);
uninstallIntent.addCategory(Intent.CATEGORY_DEFAULT);
uninstallIntent.setData(Uri.parse("package:"+ detaInfo.getPackageName()));
startActivity(uninstallIntent);</span></span>
3.跳转到系统详情界面
Intent infoIntent = new Intent();
infoIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");</span></span>
<span style="font-size:18px;"><span style="font-size:24px;">infoIntent.addCategory(Intent.CATEGORY_DEFAULT);
infoIntent.setData(Uri.parse("package:"+ detaInfo.getPackageName()));
startActivity(infoIntent);
</pre><span style="font-size:24px">4.跳转到系统共享界面</span><p></p><pre name="code" class="java"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size:18px;">Intent shareIntent = new Intent();</span></span>
<span style="font-size:18px;">shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.addCategory(Intent.CATEGORY_DEFAULT);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,"我最近发现了一个很刺激的应用:");
startActivity(shareIntent);</span></span>
5.跳转到对应包名的应用界面
<span style="font-size:18px;">Intent launchIntent = pm.getLaunchIntentForPackage(detaInfo.getPackageName());
if (launchIntent != null) {
startActivity(launchIntent);
} else { </span>
<span style="font-size:18px;"><span style="white-space: pre;"> </span>ToastUtils.getToast(AppDetalActivity.this,
"此应用无法打开");
}</span><strong>
</strong>
6.直接返回主界面(手机系统界面)
<span style="font-size:18px;">Intent Intent=new Intent();
Intent.setAction(Intent.ACTION_MAIN);
Intent.addCategory(Intent.CATEGORY_HOME);
startActivity(Intent);
</span>
7.跳转到系统打电话界面(未打)
<span style="font-size:18px;">Intent intent=new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:"+map.get(ConmonNumDBContants.COLUMN_NUMBER)));
startActivity(intent);</span>
8.跳转到发短信界面
<span style="font-size:18px;">Intent intent=new Intent();
intent.setAction("android.intent.action.SENDTO");
intent.setData(Uri.parse("smsto:"+"11111"));
//数据传递
intent.putExtra("sms_body", "你好");
startActivity(intent);</span>
9.跳转到软件管理员权限页面
a.先在工程清单文件中定义<receiver
android:name="cn.itcast.admindemo.MyAdminReceiver"
android:description="@string/sample_device_admin_description"
android:label="@string/sample_device_admin"
android:permission="android.permission.BIND_DEVICE_ADMIN" >
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_sample" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
b.在src目录定义广播接收者MyAdminReceiver继承DeviceAdminReceiver,不重写任何方法
c.在drawable目录下,定义xml目录,在xml目录下定义名为device_admin_sample.xml的文件,文件内容:
//表示申请管理员要实现的功能
<?xml version="1.0" encoding="UTF-8"?>
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<reset-password />
<force-lock />
<wipe-data />
</uses-policies>
</device-admin>
d跳转到本应用的管理员权限界面
Intent intent = new Intent();
intent.setAction(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
ComponentName componentName = new ComponentName(this,
SafeDeviceAdminReceiver.class);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "想申请如下权限");
startActivity(intent);