Intent的NEW_TASK

public static int getMemoryCache(Context context){
    ActivityManager am =     (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
    int memory = am.getMemoryClass();
    if((Build.VERSION.SDK_INT >=    Build.VERSION_CODES.HONEYCOMB) && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP != 0)){
    memory = am.getLargeMemoryClass();
}
    return memory;
}

如果一个activity通过startService启动一个service后,service又在它的方法里启动该activity,则需要设置intent的flag为NEW_TASK;否则会崩溃

猜你喜欢

转载自blog.csdn.net/su_buju/article/details/53572538