android 安装APK 卸载程序 判断设备是否有存储卡 全屏显示
1 打开内置的APK Installer来安装APK(需要将Application Setting中的Unknown sources打开)
1
2
3
4
5
6
7
|
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);
|
卸载程序
1
2
3
|
Uri packageURI = Uri.parse( "package:com.android.myapp" );
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
|
2 判断设备是否有存储卡
1
|
import static android.os.Environment.*;
|
1
2
3
|
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);
|