/**
* 分享
*/
private void share() {
/**
* Intent
{
act=android.intent.action.SEND
typ=text/plain
flg=0x3000000
cmp=com.android.mms/.ui.ComposeMessageActivity (has extras) intent中包含信息
} from pid 228
*/
Intent intent=new Intent();
intent.setAction("android.intent.action.SEND");
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "发现一个很好用的软件"+appInfo.getName()+"推荐给你,百度搜索下载");
startActivity(intent);
}
/**
* 详情
*/
private void detail() {
/**
* Intent
{
act=android.settings.APPLICATION_DETAILS_SETTINGS action
dat=package:com.example.android.apis data
cmp=com.android.settings/.applications.InstalledAppDetails
} from pid 228
*/
Intent intent=new Intent();
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.parse("package:"+appInfo.getPackageName()));
startActivity(intent);
}
/**
* 启动程序
*/
private void start() {
PackageManager pm=getPackageManager();
//获取应用程序启动意图
Intent intent=pm.getLaunchIntentForPackage(appInfo.getPackageName());
if (intent!=null) {
startActivity(intent);
}else{
Toast.makeText(getApplicationContext(), "系统核心程序不能启动", 0).show();
}
}
private void uninstall() {
/**
* <intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
*/
//判断是否是系统程序
if (appInfo.isUser()) {
//判断是否是在卸载自己
if(!appInfo.getPackageName().equals(getPackageName())){
Intent intent = new Intent();
intent.setAction("android.intent.action.DELETE");
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("package:"+appInfo.getPackageName()));//tel:110
startActivityForResult(intent,0);
}else{
Toast.makeText(getApplicationContext(), "文明社会,拒绝自杀", 0).show();
}
}else {
Toast.makeText(getApplicationContext(), "系统程序请先root", 0).show();
}
}