网上看到AlertDialog,今天在Laucher项目中用到了.
new AlertDialog.Builder(context)
.setTitle("行车记录仪")
.setMessage("是否打开")
.setPositiveButton("是", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
gotoApp(CAMERA_PACKET,CAMERA_CLASSNAME);
}
})
.setNegativeButton("否", null)
.show();
gotoApp()根据包名和类名打开一个应用
private void gotoApp(String packetName,String className){
try {
sendMsg(Contacts.HEX_OTHER_MODEL);
Intent intent = new Intent();
intent.setClassName(packetName, className);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}