根据包名字符串跳转Activity

时间:2023-03-08 19:47:32
/**
* 跳转到对应activity
*/
public void toActivity(Context context,String fullName) {
if (className != null && className.length() > 0) {
try { Intent intent = new Intent(context, Class.forName(fullName)); context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
fullName为完整类名,如com.example.app.MyActivity