调用Android系统应用时解决SDK不兼容问题

时间:2021-10-18 15:20:15

1.调用Android系统应用时,例如系统图库,我选择显示跳转。

2.Android4.3和Android5.11的包名是不一样的

3.这是5.11的系统图库包名

com.android.gallery3d.app.GalleryActivity;


4.这是4.3系统图库包名

com.android.gallery3d.app.Gallery

5.如何不进行SDK版本判断,就会出现安装程序失败的问题!

解决办法:

if (Build.VERSION.SDK_INT >= 22) {

Intent intent =new Intent();

intent.setClassName("com.android.gallery3d","com.android.gallery3d.app.GalleryActivity");

startActivity(intent);


} else {


Intent intent =new Intent();

intent.setClassName("com.android.gallery3d","com.android.gallery3d.app.Gallery");

startActivity(intent);

}


增加if (Build.VERSION.SDK_INT >= 22) 进行判断,不通版本调用不同的包名。

ps:或许会有更好的方法解决此问题,本人初学,目前只了解到这一种!