Android 学习4
1 打开内置的APK Installer来安装APK(需要将Application Setting中的Unknown sources打开)
Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.intent.ACTION_VIEW); FILE f = new File(apkFileName); //need android.permission.INSTALL_PACKAGES intent.setDataAndType(Uri.from(f),"application/vnd.android.package-archive"); startActivity(intent);
卸载程序
Uri packageURI = Uri.parse("package:com.android.myapp"); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); startActivity(uninstallIntent);
2 判断设备是否有存储卡
import static android.os.Environment.*;
boolean existSDCard = false; if(getExternalStorageState().equals(MEDIA_MOUNTED)) existSDCard = true;
3)全屏显示
//必须在setContentView之前调用全屏显示 requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);